Using buttons and switches with AVR microcontrollers

In most designs you might want to put buttons and switches to control your program flow. This is not very difficult to read button state. You can connect button between pin and ground with internal pull up enabled. Then when button is pressed, then pin value will be”0” when released – “1”. Of course you can use external pull-up resistor.

image001.gif

In fact all mechanical contacts have their shortcomings – they generate multiple micro connections that can confuse AVR. Delay of this effect depends on quality of buttons or switches and can vary from 10 to 100ms.

image004.gif

Usually this effect is removed in programming stage by using delays for waiting switch stage to become stable.

If you want to put more buttons than you microcontroller have pins, you can construct matrix style button system:

image003.gif

You see with only 8 pins you can read 16 buttons. All other job will do your algorithm.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

To submit your comment, click the image below where it asks you to...