In this tutorial we will look at how to read the status of a switch and control the led depending on the switch status. Refer the AVR I/O Register Configuration tutorial for basics of GPIO register configuration.

Basic

Starter AVR has ATmega32 micro controller and has two LED's and two user switches on board. we'll use the same for this example so no extra hardware is required. I am using switch connected to PD3 and LED connected to PD5. Dump the code and press the SW2 on board, you will find that LED2 will change state according to the switch status.

Hookup

Starter2.JPG

Code

Demo

0 Switch Starter AVR.gif

Downloads

Download the complete project folder from the below link: https://github.com/ExploreEmbedded/ATmega32_ExploreStarterAvr/archive/master.zip


Have a opinion, suggestion , question or feedback about the article let it out here!