Skip to content

Instantly share code, notes, and snippets.

@salmanfarisvp
Last active March 19, 2018 17:14
Show Gist options
  • Save salmanfarisvp/588be3f8e795dec547357266b6436ef8 to your computer and use it in GitHub Desktop.
Save salmanfarisvp/588be3f8e795dec547357266b6436ef8 to your computer and use it in GitHub Desktop.
/*
* Main.c
*
* Created: 3/19/2018 9.11.32 PM
* Author : Salman Faris
*/
#define F_CPU 20000000UL //Clock 20-Mhz
#include <avr/io.h>
int main(void)
{
DDRA |= (1<<3); //Set PA3 as OUTPUT
DDRA &=~ (1<<2); //Set PA2 as INPUT
while (1)
{
if(PINA & (1<<2)) //check PA2 is HIGH
{
PORTA = PORTA|(1<<3); // set PA3 as HIGH(ON)
}
else
{
PORTA &=~(1<<3); //set PA3 as LOW (OFF)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment