Simon Walters at Cymplecy has modified Scratch so it can be used to control the GPIO pins.
In this tutorial, I will show you how to control the LEDs through Scratch and the Pi.
Install Scratch GPIO
Follow the instructions at Cymplecy to install Scratch GPIO on your computer. Once installed, start it up and you’ll see it looks similar to Scratch.
Resistors (typically about 50 ohm)
Wires – female to male
Note that the long leg on the LED is positive and needs to be on the side where the wire comes from the output pins.
The Pi has a number of GPIO pins for OUTPUTS. You can use 11,12,13,15,16 or 18. The odd numbers are on the left and the evens are on the right.
Scratch has a BROADCAST function. You can create a BROADCAST message for the pins.
or BROADCAST PIN11ON
So when you connect a function such as
WHEN SPACE BAR PRESSED, BROADCAST PIN11HIGH
The LED will light up. If it does not work, check your wiring. If you connect the wire from Pin11 to Pin1, this supplies 3.3V and the LED will light up.
To turn the LED off,
or BROADCAST PIN11OFF
You can also control Power by creating a VARIABLE
Create a VARIABLE called Power11.
You can then set the VARIABLE to a number between 0 and 100.
You can connect multiple LEDs by using a common GROUND.
Once you have control over the LEDs, you can link it to the Scratch program and make things happen.
Instead of LEDs, you can use simple buzzers as OUTPUTS. Don’t use motors as they need more power than the Pi can supply.