#include #include #define f_CPU 20000000 #define TX PA5 #define RX PA4 SoftwareSerial mySerial(RX, TX); void setup() { mySerial.begin(9600); DDRB=0b0000; //switch is input in PB2. give all PB pins as input. DDRA=0b11111111; //LED is output in PA7. giving all PA pins as output. PORTB|=(1<<2); //pull-up PB2 internally } void loop() { if (!(PINB&(1<<2))) //if PB2 is 0, this condition is fulfilled { mySerial.print('0'); delay(500); mySerial.print('1');//switch on LED in PA7 } //return 0; }