top of page

What we will learn: How inputs work on the GPIO pins, If/Else statements, forever loops, cloning, changing colour. You will be combining a physical button that will act as in input into Scratch.  This is a key part of our game and drum machine we will build!

​

What we will need:

 

1 button

 

2 male jumpers

​

 

 

 

 

 

What we will do:

​

1.First set up your breadboard with a button which you will need to run into a GPIO pin and a ground 

 

 

 

 

 

 

 

2.Then we need to make our button INPUT into our GPIO pin. 

I chose GPIO 4

ground button here

jumpers must be straight across from button

2.Then we are setting an If/Else statement.  If the current is HIGH (which it is until the button cuts it off) then nothing happens.  Else (when we push the button the current is cut and set to LOW) change colours!

3.Finally we create  a clone of the ball and set it to randomly move around the x/y axis.  Look closely at the x and y numbers!

Taking it Further

Why not try hooking up another button to change another shapes colour?

bottom of page