Please select an option to see content specific to your location and shop online.

  • Free delivery on orders over £50 Free delivery on orders over £50
  • Free Returns Free Returns
  • Next day deliver (ordered before 16:00 GMT) Next day deliver (ordered before 16:00 GMT)
  • Super Fast Shipping from £2.99 Super Fast Shipping from £2.99

Project

Make a blinking LED

Learn how to turn an LED on and off using Scratch 2

Scroll down

1. Prepare LED connections

1. Prepare LED connections

  • Connect a jumper wire to the positive (longer) leg of the LED and to any leg of the 3.3K Ohm resistor
  • Connect another jumper wire to the other leg of the 3.3K Ohm resistor
  • Connect a jumper wire to the negative (shorter) leg of the LED

It doesn’t matter which colour jumper wires you use, but for clarity, it’s a good idea to use black for negative and red for positive polarities.

Ensure that the resistor is connected to the positive leg of the LED

2. Connect LED to Raspberry Pi

Led on

  • Connect mouse, keyboard and monitor to the Raspberry Pi and power it up. You can learn how to do it here
  • Connect the jumper wire attached to the resistor to the 3V3 pin (top left) on the Raspberry Pi
  • Connect the other jumper wire attached to the resistor to the GND pin (3rd right) on the Raspberry Pi

Your LED should now be on.
This was a quick test to ensure that everything works fine.

Led off

  • Disconnect the jumper wire attached to the resistor from the 3V3 pin
  • Connect the jumper wire attached to the resistor to pin GP25 (11 on the right column)

3. Open & prepare Scratch 2

Navigate to scratch 2

  • Navigate to the Raspberry icon on the top left of your Raspberry Pi’s desktop and open “Scratch 2” from the “Programming“ menu

Add extension

  • Ignore the cat
  • Click on “More Blocks”
  • Click on “Add an Extension”

Pi GPIO

  • Select “Pi GPIO” and click “Ok”

4. Programme LED

4. Programme LED

  • From the “Events” menu in Scratch 2, drag “when clicked” into the right-hand panel

4. Programme LED

  • Drag “repeat” from the “Control” menu and attach it to “when clicked”

4. Programme LED

  • Drag “set gpio” from the “More Blocks” menu into “repeat”. Select “25” from the “set gpio” dropdown

4. Programme LED

  • Drag “wait secs” from the “Control” menu and place it under “set gpio”
  • Drag another instance of “set gpio” into position and set it to GPIO “25” and “output low”
  • Drag another instance of “wait 1 secs”

You’re all set!

5. Test it

Click the green flag

  • To see your programme in action , click on the green flag on the top right of the Scratch 2 preview window

Your LED should now be flashing on and off every second. 
You can experiment with different timings by changing the “wait” timings.

Blinking LED

Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.