Project b7 sloppy switches – Elenco XP&trade User Manual
Page 41
Project B7
Sloppy Switches
Optional:
-40-
The program tells the microcontroller to
monitor input pin 3, where the press
switch is connected. Every time the
switch is pressed, the microcontroller is
to toggle (turn on or off) the red LED
(D1) at output pin 0.
The input pins on the microcontroller
have two states - 1 (on, or high, or
having strong voltage) or 0 (off, or low,
or having no voltage). If the electrical
signal is somewhere between these, the
microcontroller may get confused.
Build the circuit as shown. Turn on the slide switch (S1). Load program
Sloppy Switches into the microcontroller (U21) using the programming
instructions in project B1.
Push the press switch (S2) several times. Each time you press it the red LED
(D1) should toggle (turn on or off). But sometimes it will just flicker and not
change. Press the switch enough times to see this happen.
This effect makes it appear the switch isn’t working, or the microcontroller
isn’t watching it carefully enough. Do you know what is really happening?
Most switches use a metal contact that snaps into place. This action may
cause the switch to bounce and produce “switch noise” when it is closed. This
can cause equipment to think the switch was pressed more than once, and
so cause improper operation.