Switch¶
A switch is one of the most basic input components in electronics. Unlike a button that is momentary, a switch stays in its positionโON or OFFโuntil you change it. This makes it ideal for controlling power, modes, or states in your projects.
What It Does¶
This example reads the state of a switch and shows how your program can react depending on whether the switch is ON or OFF. It introduces the concept of toggle inputs, which are widely used in real devices.
Real-World Applications¶
Switches are everywhere in daily life and technology. Some common uses include:
- ๐ก Power Control โ Light switches, appliance ON/OFF switches.
- ๐ Smart Homes โ Controlling fans, lights, or connected devices.
- ๐ฎ Mode Selection โ Changing between game modes or difficulty levels.
- ๐ค Robotics โ Enabling/disabling features, reset switches, or safety locks.
- ๐งช STEM Projects โ Teaching logic control, toggling states, or acting as a manual override.
With a switch, students learn how devices store state and how physical inputs can control digital systems.
โ Once you can read a switch input, you can use it to turn LEDs on/off, change motor states, toggle alarms, or even switch between entire program modes.