A slide switch is a switch which can be set in one of two positions.
By placing a slide switch in an appropriate circuit and connecting to a PICAXE input pin the PICAXE can determine the position of the slide switch.
Slide Switch
Schematic
PCB
Slide switch position detection
The following program will turn a LED connected to output pin B.1 on when the slide switch connected to input pin C.0 is activated and turn the LED off when not activated.
- Code Example:
-
main: if pinC.0 = 1 then high B.1 ; Turn LED on else low B.1 ; Turn LED off end if goto main
Copy Code Submit an Example
Create Module
The slide switch create module provides an input signal to the PICAXE on the motherboard. The input signal will read high (1) when the slide switch is activated and read low (0) when it is not.
Bill of Materials
Description | Code | Qty | |
---|---|---|---|
Miniature SPDT PCB mounting slide switch | SEN021 | 1 | Buy Now |
10k resistor (pack 100) | RES10K | 1 | Buy Now |
Simulation
Submit Your Own Code!
You must be logged in to submit code examples. Login now.
Share