Force Sensitive Resistor Activated Led

by Shade x Legend in Circuits > Arduino

3042 Views, 10 Favorites, 0 Comments

Force Sensitive Resistor Activated Led

IMG_0403.JPG

Hey Guys! We are going to be using a fsr to turn an led on and change the brightness. You are going to need:

-FSR http://www.amazon.com/gp/product/B00B887CLS/ref=oh...

-arduino uno

-LED

-breadboard

-jumper wires

Downloads

Setting Up the Circuit

IMG_0402.JPG

first put the fsr anywhere in the breadboard. the put to jumper wires in the row with each lead. Then put one lead to the positive terminals on your breadboard and the other to pin A0 on your arduino. Next put a jumper wire from the positvie terminals to gnd on your ardunio. Then put your led of any color anywhere on your breadboard, preferably on the same half as your fsr. Then take two jumper cables and put them in the same row as the led leads and one will go to the positive terminals on your breadboard and the other to pin 9 on your arduino.

Writing the Code

/* Made By: Logan Crawfis

FSR to light LED --------------------------

*/ int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 9; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor

void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin, OUTPUT); }

void loop() { // read the value from the sensor: sensorValue = analogRead(sensorPin); if(sensorValue > 1000){ //if the value is greater than 1000 it will light the led digitalWrite(ledPin, LOW);//change the greater than to a less than for it to turn off when you push } else digitalWrite(ledPin, HIGH); }