Last active
April 5, 2016 10:20
-
-
Save raghavendrahassy/54c2d30d52ae16c6a1e8b4d428ffe5c1 to your computer and use it in GitHub Desktop.
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> | |
#include <util/delay.h> | |
#define LED PB0 | |
#define SWITCH PC0 | |
int main() | |
{ | |
DDRB = (1 << LED); // Configure PORTB as output to connect Leds | |
DDRC = (0 << SWITCH); // Configure PORTC as Input to connect switches | |
PORTC = (1 << SWITCH); // Enable The PullUps of PORTC. | |
while(1) | |
{ | |
while(((PINC) & (1<<SWITCH)) == 1) // Check the status of the switch | |
{ | |
PORTB |= (1<<LED); | |
} | |
PORTB &= ~(1<<LED); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment