Toggle Switch

Toggle Switch 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

// Turns the LED on if switch is set to on if ( awesome.toggleSwitch.isOn() ) { awesome.LED.turnOn(); }

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

// Turns the LED off if switch is set to OFF if ( awesome.toggleSwitch.isOff() ) { awesome.LED.turnOff(); }

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

awesome.toggleSwitch.print();

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().

x

Hi awesome backer,

Thanks again for supporting us on Kickstarter or Indiegogo.

On this website you can access the learning videos and documentation. You'll need to sign up for an account but it shouldn't take long and allows us to remember your video progress so you don't have to keep track of that.

We hope you have a great time learning with Awesome Shield.


Close Message