Toggle Switch
A latching source: one click flips it between logic LOW (0) and logic HIGH (1), and it holds that state until you click again. Where a button returns on its own, a switch remembers, which makes it the natural choice for a setting or mode that must stay put. It models a real single-pole toggle, whose defined level depends on whether it is wired with a pull-up or a pull-down resistor.
Toggle and hold
Click the switch to flip its output from 0 to logic HIGH (1); click it again to flip back to logic LOW (0). Between clicks the value stays exactly where you left it, so a switch is ideal for a persistent input such as an enable line or a select bit.
| Position | Output |
|---|---|
| OFF | 0 |
| ON | 1 |
Pull-up versus pull-down
A real toggle only opens or closes a contact; a resistor decides the idle level. Wired with a pull-up resistor to VCC, the line sits at logic HIGH (1) when the switch is open and drops to 0 when it closes to ground, giving an active-low signal. A pull-down to ground reverses this. The simulated switch abstracts the wiring and simply outputs a clean, held 0 or 1.
Enable and select lines
Because it holds its state, a switch is perfect for a control input that must stay constant: an enable that gates a counter, or a select bit that routes a multiplexer. Set it once and the rest of the circuit sees a stable level for as long as needed, without any manual holding.
Citations
- Texas Instruments. (2011). Choosing an appropriate pull-up/pull-down resistor for open drain outputs (Report No. SLVA485). Reference 1
- Horowitz, P., & Hill, W. (2015). The art of electronics (3rd ed.). Cambridge University Press. Reference 2