Last active
January 2, 2016 23:49
-
-
Save RaspPiGuy/8378773 to your computer and use it in GitHub Desktop.
For my blog: thepiandi.blogspot.com Demonstrates ATmega register programming to tuirn Gertboard LEDs on and off in sequence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
void setup(){ | |
// PB0, PB1, PB2, PB3, PB4, PB5 connect to LEDs so must be outputs | |
DDRB = 0b00111111; | |
// All LEDs off | |
PORTB = 0X00; | |
} | |
void loop(){ | |
// Turn LED at PB0 on | |
PORTB |= (1 << PORTB0); | |
delay(1000); | |
// Turn LED at PB0 off, LED at PB1 on | |
PORTB &= ~(1 << PORTB0); | |
PORTB |= (1 << PORTB1); | |
delay(1000); | |
// Turn LED at PB1 off, LED at PB2 on | |
PORTB &= ~(1 << PORTB1); | |
PORTB |= (1 << PORTB2); | |
delay(1000); | |
// Turn LED at PB2 off, LED at PB3 on | |
PORTB &= ~(1 << PORTB2); | |
PORTB |= (1 << PORTB3); | |
delay(1000); | |
// Turn LED at PB3 off, LED at PB4 on | |
PORTB &= ~(1 << PORTB3); | |
PORTB |= (1 << PORTB4); | |
delay(1000); | |
// Turn LED at PB4 off, LED at PB5 on | |
PORTB &= ~(1 << PORTB4); | |
PORTB |= (1 << PORTB5); | |
delay(1000); | |
// Turn LED at PB5 off | |
PORTB &= ~(1 << PORTB5); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment