Pressing-Button w/ Atmel Studio 7 & UNO Serie (Episode#03)
By pressing the touch button (Arduino Pin 7), turn on LED (Arduino Pin 8).
Let’s get started!

In order to use the interrupt, we will choose a button to begin the whole process in our search for the methods of sleep (energy saving).
Step#01→ choose 2 pins: LED Attach -> Pin 0 of PORTB (Arduino Digital 8); Switch Key -> Pin 7 of PORTD (Arduino Digital 7) ;
By looking in datasheet he is the code:
The first we are setting Pin 0, Port B (Arduino Digital 8); The second clearing Pin 7, Port D (Arduino Digital 7)
DDRB |= (1<<DDB0);
DDRD &= ~(1<<DDD7);Step #02→ Defining the basics macros for clears the code:
#define LedOn PORTB |= (1<<PORTB0)
#define LedOff PORTB &= ~(1<<PORTB0)
#define LedToggle PINB |= (1<<PINB0)Step #03→ The secret is that fragment:
if (!(PIND & (1<<PIND7)))The button sends zero volts to pin D7; so we wait just this moment … cool is not it?
Step #04→ Here is the complete code;
https://gist.github.com/giljr/3788f45584feb4c5146af7fc70326fe4
In the next post we are using Interruptions instead of polling techniques. Stay Tuned!
See all the serie:
Atmel Studio 7 & UNO Serie (Ep#00) @giljrE https://readmedium.com/atmel-studio-7-uno-ep-00-969b9cc3cf7b
References & Credits
Follow along with the entire ‘Getting Started with AVR’ series: http://bit.ly/GettingStartedwithAVR
→Goto Episode#04
Complete Serie:
#00 HowTo-Load-Into-Arduino-AS7
#03_Pressing-Button
#08
#09
#10






