From 3fbd0e8b51072ed370fd0cb1f01d4bb85c978652 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Sat, 20 Sep 2014 03:32:04 +0300 Subject: Update code to test all LEDs --- hello.c | 57 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'hello.c') diff --git a/hello.c b/hello.c index 2d1ba75..e475624 100644 --- a/hello.c +++ b/hello.c @@ -1,32 +1,35 @@ + #include -// F_CPU frequency to be defined at command line #include -// 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); - - while (1) { - high = !high; - - if (high) { - PORTB |= (1 << LED); - } else { - PORTB &= ~(1 << LED); - } - - for (ms = DELAY_MS; ms > 0; ms -= 10) { - _delay_ms(10); - } - } - - return 0; +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); + + PORTB ^= _BV(PB1); + _delay_ms(500); + PORTB ^= _BV(PB1); + + PORTB ^= _BV(PB2); + _delay_ms(500); + PORTB ^= _BV(PB2); + + PORTB ^= _BV(PB3); + _delay_ms(500); + PORTB ^= _BV(PB3); + + PORTB ^= _BV(PB4); + _delay_ms(500); + PORTB ^= _BV(PB4); + } } -- cgit v1.3.1