top of page

What you will learn: how to combine inputs and outputs, use a button as an input to turn an LED on and off

​

What you will need:

1 x LED

1 x button

4 x male to male jumper cables

​

What you will do: Wire up your breadboard

​

​

​

Ground your button to the - symbol !!

Ground your LED

to the - symbol

Our button is an INPUT

Bring out the 'set gpio block and change it to an input, our button is an input, it is going into our Raspi!

Bring out the 'forever' and 'if else' blocks then place the gpio block inside the if block.  If something happens we want our LED to turn off! Else we want it to turn on.

Next set the gpio pins to low and high to turn the LED on and off if the button is pressed.  Also make your cat say when the LED is on or off

there is something wrong here! what GPIO are you using as your input (the wires leading from the button!

there is something wrong here! what GPIO are you using as your output(the wire leading to your LED!

OK so now you have a HUGE problem.  It's not working! What do you think could be wrong? Check the pink hints above to figure it out.  You will have to debug. 

Taking it further

Can you make the cat say "on" when the light is on and "off" when the light is off?

bottom of page