Introduction: Raspberry Pi - GPIO Scratch LED Control

Picture of Raspberry Pi -  GPIO Scratch LED Control

For this project I will show you how to control an LED with GPIO scratch using a raspberry pi. A Raspberry Pi is a fully-fledged yet credit card sized computer that can be used in a huge variety of electronics projects because of its ability to interact with hardware. One of the ways of doing so, is by using the pi's GPIO pins (General Purpose Input Output pins). These allow you to play around with prototyping breadboards, motors, LEDs, switches... and many more electronic components. You are going to use the GPIO pins to blink a single LED today that will help with your Pi understanding. This was one of the first ever projects I used the Pi for and I was delighted after seeing that LED light up. This is a fantastic project for beginners and I hope it gives you some idea about the amount of scope you have with the pi. Good Luck

(please note this project doesn't cover how to install Raspbian Wheezy onto an SD card or how to connect the raspberry pi to a monitor, keyboard, mouse or a network )

Step 1: Electronic Components

Picture of Electronic Components

For this project you will need:

  1. An LED (any colour will do)
  2. A prototyping breadboard
  3. 2 wires or jumper-wires
  4. A raspberry pi model B with Raspbian Wheezy installed and connection to a network
  5. A 330 ohm resistor (I didn't have one so I used a 280 ohm one)
  6. A 26 pin GPIO breakout board ( you will not need this if you have jumper-wires)

Step 2: Installing Scratch GPIO

Picture of Installing Scratch GPIO

The first step is to install Scratch GPIO. Scratch is a drag and drop programming language that is great for beginners. Scratch GPIO allows you to interact with the GPIO pins on the pi. Log into your pi and open the terminal. are going to use the commands 'sudo apt-get update' and 'sudo apt-get upgrade'. Now head over to http://simplesi.net/scratchgpio/scratch-raspberrypi-gpio/ to get the other two commands for the install. The longer one is for the install and the shorter one is for the scratch GPIO itself. Once installed you should have the Scratch GPIO on your desktop.

Step 3: Connecting All the Hardware

Picture of Connecting All the Hardware

Next, you are going to connect all of the electronic components. The black wire (ground pin or pin 6 it is marked as GND from the breakout board) goes to the top row of holes that runs along to the short leg of the LED. Then once the LED is in place, put the resistor down in front of the long leg of the LED. Once the resistor is in place, put the red wire (TXD pin or pin 8) in front of the resistor. This completes you circuit. Use the pictures to help you.

Step 4: Blinking the LED

Picture of Blinking the LED

Finally, connect the breakout board or jumper wires to the pi and log into it. Then open Scratch GPIO and you are ready to start. Firstly, drag and drop a when spaced bar clicked buttononto the script. Now drag a Broadcast block from the controlsection into the script area. Click this block and select new/edit and type 'pin8on'. Now drag a wait one second block into the script area. Lastly, drag a Broadcastbutton into the script area and type 'pin8off'. This completes your very simple blinking LED script. You can now try more complex scripts as they run along the same lines. Well done for completing this project and thank you for viewing this it. I would love for you to look at some of my others projects as I work super hard to produce opefully great and velivant content for you.

thanks

Chris_maker

Comments

OscarS51 (author)2016-08-01

A nice teaching.

Could you kindly though indicate where to order a 26 pin GPIO breakout board ?

chris_maker (author)OscarS512016-08-31

I got my breakout board from Maplin electronics.

Yorgy (author)2016-08-21

In step two you mentioned a website. I'm going to try to make a link for it. www.simplesi.net/scratchgpio/scratchrasberrypi-gp...

There it works.

chris_maker (author)Yorgy2016-08-31

Thank you Yorgy

About This Instructable

1,813views

9favorites

License:

Bio: Hi, I am Chris and I have a passion for engineering and designing. I love innovation and new ideas. I hope some of my projects ... More »
More by chris_maker:5 Genuinely Useful Things to 3D Print Solar Shed - One Year LaterThe Solar Shed
Add instructable to: