I currently have a working prototype of an arduino duemilanove programmed to turn 1 LED on when FSR (force sensing resistor) is pressed.
I need to have 14 LEDs, so I will be wiring them in parallel.
I just need some guidance on how to wire it through the breadboard, and the associated coding to switch all 14 LEDs on when the FSR is touched.
Here is the current working code for 1 LED
/* FSR testing sketch.
Connect one end of FSR to 5V, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
Connect LED from pin 11 through a resistor to ground
For more information see www.ladyada.net/learn/sensors/fsr.html */
int fsrAnalogPin = 0; // FSR is connected to analog 0
int LEDpin = 13;// connect Red LED to pin 11 (PWM pin)
int fsrReading; // the analog reading from the FSR resistor divider
int LEDbrightness;
void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
pinMode(LEDpin, OUTPUT);
The circuit needs 140mA at 9 volts. An Arduino pin is going to give you 40mA at 5 volts.
You can use a transistor to make the pin control more current, or you can spread the LEDs across multiple pins, for example use 7 pins to drive 2 LEDs each.
int LEDpin = 13;// connect Red LED to pin 11 (PWM pin)
It's nice when the useless comments match the code.
if(fsrReading) {
The analogRead function returns a value between 0 and 1023, depending on how much force is applied to the sensor. A change in value from one reading to the next of less than 2 is considered noise.
If fsrReading what? As written now, ANY pressure on the sensor will cause a non-zero reading, as will any variation in voltage applied to the sensor, as will any (electrical) noise in the environment. It seems unlikely that ANY of these things should cause the LEDs to turn on for 5 seconds.
if(fsrReading > threshold) seems more useful. Experiment to determine what value threshold should have to prevent false alarms.
You can use a transistor to make the pin control more current, or you can spread the LEDs across multiple pins, for example use 7 pins to drive 2 LEDs each.
You can't drive load connected to 9 Volt directly by arduino, except you wanna to fry it.
Transistor or relay is must be present.
I'm very new to this, so excuse the ignorance! But can anyone explain how the breadboard maps to the arduino in terms of the code, and how that changes from how it is now?
It's for an interactive stairway lighting system. So basically I have a model of a staircase, which will have one LED per step. When pressure is applied to the bottom step (via the FSR), I need all 14 LEDs to switch on for about 20 sec and then switch off.
My focus is on the system design and interaction, so I'm struggling a bit with no background in electronics. I understand what I have so far for a couple of LEDs, but having 14 is complicating things!!