beautypg.com

Project 7: switches and digital inputs – Elenco Snap Circuits SnapMicro I Deluxe ® User Manual

Page 38

background image

37

Project 7: SWITCHES AND DIGITAL INPUTS

Digital Inputs

A digital input can only be ‘on’ or ‘off’. Some examples of a digital inputs found in Snap Circuits

®

are:

• Push Button Switch

Always ‘OFF’ when released

• Slide Switch

Stays ‘ON or ‘OFF’ after switching.

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. The program below should change the state of the LED

each time the Push Button switch is pressed. In this program output pin 4 toggles (changes state) every

time the push switch on input pin 3 is pressed.

Using the Program Editor construct the flowchart shown here. Then use the PICAXE

®

menu to convert it

to a program similar to the program on the right. When the program on the right was edited for clarity,

the ‘pause 100’ was added as a note. This should be made a command by removing the apostrophe in

front of the “pause” if the switch is very noisy when pressed or released.

Save program, then build circuit on next page.

This manual is related to the following products: