Tag Archives: LED

Arduino microcontroller

Using the Arduino to make an LED glow

We’ve been using both the Arduino and the Raspberry Pi to control LEDS, motors, switches and sensors. I’m going to do a series of simple tutorials explaining how both can be used as control devices and explain to teachers – especially primary teachers – how the National Curriculum for computing can be taught in the classroom in an interesting way.

The Arduino


Arduino microcontroller

An Arduino microcontroller. Each pin can control and input or and output.

It’s got pins which can be used for input and output. To set it up, you need the Arduino IDE which can be downloaded from the Arduino website.

Once set up, you connect it to the computer with a USB cable. You need to select the correct serial port.

Scratch for Arduino

This is a free adaptation of the popular Scratch program. It has been modified so you can turn pins on and off, give pins a variable power output, control motors and servos and also read sensors with an analogue input. This gives it a massive advantage over the Pi which can only read a digital input.

Download Scratch for Arduino here.

Once you upload the firmware in the Arduino program, you can then activate S4A. It searches for the board. Once detected, a sensor board comes up showing you 6 analogue inputs and the value of pin 2 and pin 3.

So to make an LED light up.

You need a breadboard, 2 wires, a resistor (about 400 ohm – but depends on the LED) and an LED.

Connect one wire to the 5V pin. Connect the other end to the breadboard along with the LED and resistor. The other wire connects to the GROUND  on the Arduino. Look at the diagram to see how the circuit works. If it’s correct, the LED will light up. Common mistakes include the LED being the wrong way round (long wire on the positive side) or too high an LED.

Once that works, disconnect the wire from the 5V and put it in pin 10 (or 11, 12 or 13).


The commands are as for normal Scratch. So if you select



Then when you press the SPACE key, digital 10 will turn on and the LED will light up.

To turn it off, DIGITAL 10 OFF.

S4a basic LED

It’s that simple.

To make things more interesting, you can connect multiple LEDs with a common ground to pins 10, 11, 12 and 13.

If you want to alter the degree of power, use pins 5,6 and 9. In this case, you use ANALOG 5 (0 – 255) where 0 is no power and 255 is full power.