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.

Blogsphere: TechnoratiFeedsterBloglines
Bookmark: Del.icio.usSpurlFurlSimpyBlinkDigg
RSS feed for comments on this post
 |  TrackBack URI for this post

New on WinAVR Tutorial
Running TX433 and RX433 RF modules with AVR microcontrollers,
Sometimes in embedded design you may want to go wireless. Might be you will want to log various readi …
Programming AVR ADC module with WinAVR,
Most of AVR microcontrollers have Analog to Digital Converter (ADC) integrated in to chip. Such solut …
New on WinARM Tutorial
What are differences between WinARM and WinAVR,
Everyone who is working with AVR microcontrollers knows this powerful tool – WinAVR (http://win …
LPC2000 watchdog timer,
As in all microcontrollers watchdog timers purpose isto reset microcontroller after reasonable amount …

Leave a Reply