You are on page 1of 3

; The below program will try to broadcast a short message via Morse code on the LED

.The program will blink a 3 letter sequence .

; It includes the first three letters of my Surname which are 'B','H','E'. With the
help of the International Morse Code table the required dots and dashes can be
figured out.

led_on.s ; switches on the Arduino LED

; specify equivalent symbols


.equ SREG, 0X3F ; Status register
.equ PORTB, 0x05
.equ DDRB, 0x04

; specify the start address


.org 0

main: ; reset system status


ldi r16,0 ; set register 16 to zero
out SREG,r16 ; copy contents of r16 to SREG, i.e clear SREG

; Setting output to portB pin 1


ldi r16, 0x01 ; set register 16 to 15
out DDRB, r16 ; set DDRB to bit 1

mainloop:
call dash
call space
call dot
call space
call dash
call space
call dot
call letterdelay

call dot
call space
call dash
call space
call dot
call letterdelay

rjmp mainloop

; Morse code dot output


dot: ldi r16, 0x01 ;set register r16 to 1 or binary 1 on bit 0
out PORTB, r16 ; copy contents of r16 to PORTB

call delay

ret

; Morse code dash output


dash: ldi r20, 3
ldi r16, 0x01 ;set register r16 to 1 or binary 1 on bit 0
out PORTB, r16 ; copy contents of r16 to PORTB

ldi r20, 3
loop4: call delay
dec r20
cpi r20, 0
brne loop4

ret

; Morse code letter delay


letterdelay: ldi r20, 3
loop5: call delay
dec r20
cpi r20, 0
brne loop5
ret

; 200ms delay subroutine defined


delay: ldi r19, 20

loop1: ldi r17, 128

loop2: ldi r18, 250

loop3: nop
dec r18
cpi r18, 0
brne loop3

dec r17
cpi r17, 0
brne loop2

dec r19
cpi r19, 0
brne loop1

ret

You might also like