//1) Create two LED variables on pins “A0” and “A7”
var led1 = createLed(“A0”);
var led2 = createLed(“A7”);
//2) When the toggleSwitch is closed:
//turn on the colorLEDs and turn off the external LEDs
onBoardEvent(toggleSwitch, “close”, function() {
//Turn on the colorLEDs
colorLeds[0].on();
colorLeds[1].on();
colorLeds[2].on();
colorLeds[3].on();
colorLeds[4].on();
colorLeds[5].on();
colorLeds[6].on();
colorLeds[7].on();
colorLeds[8].on();
colorLeds[9].on();
//turn off the external LEDs
led1.off();
led2.off();
});
//3) When the toggleSwitch is open:
//turn off the colorLEDs and turn on the external LEDs
onBoardEvent(toggleSwitch, “open”, function() {
//Turn off the colorLEDs
colorLeds[0].off();
colorLeds[1].off();
colorLeds[2].off();
colorLeds[3].off();
colorLeds[4].off();
colorLeds[5].off();
colorLeds[6].off();
colorLeds[7].off();
colorLeds[8].off();
colorLeds[9].off();
//turn off the external LEDs
led1.on();
led2.on();
});
This is the teacher example for this level but code does not work with the Circuit Playground Express.
A7 seems to be a reserved pin and the other error is that the code does not cycle the internal leds on while the external leds are off and vice versa. Does anyone have a fix for this level? I can’t seem to code it myself properly.