Look for the graphic aboveLet there be light! Learn to use buttons to control LEDs
Students have learned how to build circuits with buttons and LED lights, now they will learn how to use the status of buttons (pressed is ON, not pressed is OFF) to turn an LED light on and off.
Piper Computer Kit
3 Buttons (red, yellow, green)
3 LEDs (red, yellow, green)
12 Wires (4 red, 4 yellow, 4 green)
Breadboard
In Blink and Stoplight students learned how to program an event output in the form of an LED.
With Lightshow, they will now check the state (or status) of inputs (buttons) to control outputs (LEDs). When a button is pressed (ON), the corresponding color of LED is turned ON so it lights up.
Take out the inventory you see in the picture below.
Wire your LED's and Buttons with the correct GPIO setup. That's a lot of wires!
Red Button Pins: 26, 24
Yellow Button Pins: 22, 20
Green Button Pins: 18, 16
Drag blocks to match the image. The While block is a new one!
Program the While block by adding a check for pin 24 (the red button) being ON.
Now program the While block to turn on pin 37 (the red LED).
When we release the button, we want the light to turn off. Add a block to turn pin 37 off.
Now repeat the pattern for the other two lights.