diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2014-09-20 03:32:04 +0300 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2014-09-20 03:32:04 +0300 |
| commit | 3fbd0e8b51072ed370fd0cb1f01d4bb85c978652 (patch) | |
| tree | c477551ebacc3deb89dc3ad49c0899fe92f1da6d /hello.c | |
| parent | da5494f5ff3c193098a0b67cd7588300021dfdbe (diff) | |
Update code to test all LEDs
Diffstat (limited to 'hello.c')
| -rw-r--r-- | hello.c | 49 |
1 files changed, 26 insertions, 23 deletions
@@ -1,32 +1,35 @@ + #include <avr/io.h> -// F_CPU frequency to be defined at command line #include <util/delay.h> -// LED is on pin 2, PB3 -#define LED PB3 -#define DELAY_MS 500 - -int main () { - uint8_t high = 0; - uint16_t ms = 0; - - DDRB |= (1 << LED); - PORTB &= ~(1 << LED); +int +main (void) +{ + DDRB |= _BV(DDB0); + DDRB |= _BV(DDB1); + DDRB |= _BV(DDB2); + DDRB |= _BV(DDB3); + DDRB |= _BV(DDB4); + while(1) { + PORTB ^= _BV(PB0); + _delay_ms(500); + PORTB ^= _BV(PB0); - while (1) { - high = !high; + PORTB ^= _BV(PB1); + _delay_ms(500); + PORTB ^= _BV(PB1); - if (high) { - PORTB |= (1 << LED); - } else { - PORTB &= ~(1 << LED); - } + PORTB ^= _BV(PB2); + _delay_ms(500); + PORTB ^= _BV(PB2); - for (ms = DELAY_MS; ms > 0; ms -= 10) { - _delay_ms(10); - } - } + PORTB ^= _BV(PB3); + _delay_ms(500); + PORTB ^= _BV(PB3); - return 0; + PORTB ^= _BV(PB4); + _delay_ms(500); + PORTB ^= _BV(PB4); + } } |
