; LEDblink.asm - M. Covington 2006
; For ATtiny13.
; Blinks the LEDs attached to PB0 and PB1.
.include "tn13def.inc"
.def temp = R16
.def temp1 = R17
.def temp2 = R18
.def mask = R19
start: ldi temp,0b00000010
out PORTB,temp ; initialize port B
ser mask
out DDRB,mask ; port B all outputs
blink:
; Delay 0.1 sec (1.2 MHz)
ldi temp1,200 ; outer loop count
L1: ldi temp2,199 ; inner loop count
L2: dec temp2
brne L2
dec temp1
brne L1
; Toggle PB0 and PB1
ldi mask,0b00000011
eor temp,mask
out PORTB,temp
rjmp blink
; End of program
So when I got to Maker Day at Maker Faire yesterday afternoon, I was happy to find that Limor Fried, the founder of Adafruit, was giving a presentation on how to start your own business selling kits. This is a growing business right now, as people look for reasons to teach their kids how to solder, or just want to build a neat device. (Adafruit teamed with the Maker Store to offer the infamous TV-B-Gone kit that garnered a lot of attention at CES this year.)
void setup(){
pinMode(13, OUTPUT);
}
void loop(){
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
First, we configure pin 13 for output by setting a bit in Data Direction Register B. Then we turn pin 13 by setting its bit in PORTB. Then we delay 500 milliseconds by marking the current value of timer0, converted into milliseconds, and letting the counter be incremented repeatedly at each clock cycle and overflowed into ever larger holders until the new value of timer0 represents an elapsed time of 500ms. Next we set the bit for pin 13 in PORTB low to turn the LED off. We do the delay dance again and we're home.