Toggle Switch
The toggle switch is a simple switch. When the switch is at the end labeled "on", it makes an electrical connection. The Arduino can detect this electrical connection. Then it can figure out of the switch is set to "on" or "off".
Main Function
awesome.toggleSwitch.isOn()
Checks if the switch is set to "on".
Returns
It returns a bool
. This bool is true
if the switch is set to "on" and false
if it is set to "off".
Example
Advanced Functions
awesome.toggleSwitch.isOff()
Checks if the switch is set to "off".
Returns
It returns a bool
. This bool is true
if the switch is set to "off" and false
if it is set to "on".
Example
awesome.toggleSwitch.print()
First the print function takes a reading from the toggle switch to see if it is set to on or off. Then it sends a message telling you whether the toggle switch is on or off through the Serial connection.
Click the magnifying glass icon in the top right hand corner of the Arduino IDE to see the messages that Arduino sends to you through the Serial connection.
Example
Tips
You can use the toggle switch to change your sketch from one mode to another. For example, one mode could silence the buzzer. It works well with if()
.