Toggle Switches - Reliable Reading

An example sketch that will read a simple toggle switch reliably, irrespective of the circuit design.

Feb 5, 2021

19515 views

4 respects

Components and supplies

1

Arduino UNO

1

Toggle Switch, Toggle

1

Resistor 10k ohm

4

Jumper wires (generic)

Apps and platforms

1

Arduino IDE

Project description

Code

Reading a Toggle Switch

c_cpp

Reliably read a toggle switch, irrespective of circuit configuration.

Comments

Only logged in users can leave comments

nouman_babar

2 years ago

code not working, when button pressed led will be on but when you leave the button then led will be off. toggle means first press led on and second press led off. and vice versa. This code waste my lot time

Anonymous user

3 years ago

This is very well put together; just at a time I needed clarity in regards to toggle switches. Thanks ever so much!