toggleSwitch
is an object representing the switch on the Circuit Playground. Internally the toggleSwitch is connected to pin 21.
toggleSwitch.isOpen
- Boolean property, true
if the switch is flipped to open, otherwise false
onBoardEvent(toggleSwitch, "close", function(event) { colorLeds[0].on(); colorLeds[1].on(); colorLeds[2].on(); colorLeds[3].on(); colorLeds[4].on(); colorLeds[5].off(); colorLeds[6].off(); colorLeds[7].off(); colorLeds[8].off(); colorLeds[9].off(); }); onBoardEvent(toggleSwitch, "open", function(event) { colorLeds[0].off(); colorLeds[1].off(); colorLeds[2].off(); colorLeds[3].off(); colorLeds[4].off(); colorLeds[5].on(); colorLeds[6].on(); colorLeds[7].on(); colorLeds[8].on(); colorLeds[9].on(); });
Found a bug in the documentation? Let us know at documentation@code.org