Lachlan Micromouse Push Buttons

Push Buttons

The rules allow you to put a couple of push buttons on your micromouse. Usually designers will place a reset button, and a start/pause button on their mouse. However adding a button is not as simple as you might think. Still adding one is easy if you know how.

Wiring the Push Button

The most common mistake, and I saw several groups make this same mistake, is using a floating input to mean '0' as shown in the diagram below. The unfortunate thing about this as anyone who has done it will discover it that it will usually float to '1' and thereby not work. One other assumption has been made in this, and that is that the input to the microcontroller is high impedance. This is not the case if there is a typo in the software and you could burn out your micro!
Bbcode image

So now for the correct way to wire up a button to a microcontroller input. Note that both resistors are important, do not neglect either one or you could blow up your micro, and short your power supply.
Bbcode imageBbcode image

Choose whichever of active low (pull-up resistor) or active high (pull-down resistor) you wish to use. The AVR reset pin has to connected via an active low circuit if you are going to put a switch on it.

It really is that simple, and will make sure that things work as intended, and you are less likely to blow something up.

De-bouncing

Depending on the mechanical properties of your push button, you will want to write a software de bouncer for it. A software de bouncer is cheaper than an electrical one, but either works as well as the other. A de bouncer ensures that when the button is pushed, it is only registered as being pushed once, and not several times.

A button will register as being pushed several times if the contact rings, just like a hammer does when striking a piece of metal. Depending on the mechanical properties of the switch you have chosen this may not be a problem, but if it is, then a simple algorithm to ignore consecutive button presses in a short period of time is required.


Last Modified: August 19, 2008 with 2 page views.