All posts by Mustafa Ahmad

Lighting multiple LEDs with sensors (force sensitive resistor or potentiometer)

This tutorial shows how to light multiple LED’s one at a time through the use of either a force sensitive resistor or a potentiometer. Since both components deal with the increase or decrease of resistance through the circuit varying the voltage (which in our case is between 0 and 5v), both can be utilized with the same code.

First and foremost you’re going to need a few parts.

PARTS REQUIRED

Parts required
Parts required

1. Arduino Kit

2. Force Sensitive Reisistor (FSR)

3. Potentiometer

4. 3 – 330 Ohm Resistors

5. 1 – 10 Ohm Resistor

6. Jumper Wires

7. 3 LED’s

8. Breadboard

LIGHTING WITH FORCE SENSITIVE RESISTORS

fsr circuit

Now that we have our parts, we’re going to start putting them together. Let’s start with the force sensitive resistor.

force sensitive resistor circuitry

Connect your force sensitive resistor to the breadboard. From there, place a 10 Ohm resistor as shown in the diagram and connect that to ground by inserting one end of the resistor on the breadboard in the same column as the black wire. On the same row as the resistor insert a jumper wire and connect the other end of the jumper wire to the A0 pin on your arduino board. The ‘A0’ pin is your analogue pin that allows the sensor to communicate with your Arduino chip. Insert a second jumper wire from the sensor to the column of pins on the bread board that connects to the 5v power supply of your arduino kit (red wire).

Now let’s start connecting our LED’s

led

Place an LED on the bread board. Once that is done place a 330 Ohm resistor from the negative end of the LED (shorter leg) to ground and a jumper wire from the positive end of the LED (longer leg) to digital pin 9. We’re using the digital pin because our LED’s are going to operate through information provided from the sensor to the arduino kit digitally.

Let’s do that for a number of LED;s.

3 LED's

So far so good! Now let’s put a code in there and try to light them up.

 

ARDUINO CODE

Let’s open up the arduino interface and start writing some code.  Make sure your arduino is disconnected while coding so nothing burns out or short circuits.

Once you’ve written the code connect your arduino port to the computer and click on the ‘upload’ icon (which is shaped like an arrow) at the top left corner of your interface (right below the edit menu).

arduino

If you run the code before connecting the arduino to your computer you might run into a serial port error.

arduino2

 

If you have gotten everything running smoothly, press on the force sensitive resistor with different pressures and watch the LED’s change.

IMG_0871

 

LIGHTING WITH A POTENTIOMETER

IMG_0862

Now let’s see how we can light up the LED’s using a potentiometer. The thing to note here is that since the code works the same we can repeat all the steps above but replace the force sensitive resistor with the potentiometer.

The circuitry:

potentiometer

 

Insert the potentiometer on to the breadboard and connect jumper wires from the breadboard to the arduino board as shown in the diagram above. The middle jumper wire should be connected to the analog 0 pin as this is going to help determine the varying resistance values that will switch between LED’s. Once the potentiometer is plugged in and you have run the code through arduino, rotate the dial on the potentiometer and watch the LED’s change.

You can potentially develop some very interesting projects with the use of LED’s and sensors especially in an urban context when there is a lot of activity and the circuit is constantly being activated.