Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raghavendrahassy/54c2d30d52ae16c6a1e8b4d428ffe5c1 to your computer and use it in GitHub Desktop.
Save raghavendrahassy/54c2d30d52ae16c6a1e8b4d428ffe5c1 to your computer and use it in GitHub Desktop.
#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