I need help again
On one breadboard I wired seven LEDS. On another breadboard I wired an extra long FSR sensor strip . I would like to be able to press the FSR strip and light up the LEDs. The more pressure, the more LEDs light up. Does anyone know how to code this project?
Thank you!
Michaela
FSR and multiple LEDs
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: FSR and multiple LEDs
The basics of working with an FSR are covered in this tutorial: http://learn.adafruit.com/force-sensiti ... ing-an-fsr
For the multiple-LED output, I'd personally use something like a dual array:
The technique is called 'tabular programming' since all the important information lives in the two tables.
For the multiple-LED output, I'd personally use something like a dual array:
Code: Select all
int LEDS = 7;
int LED[] = {
LED1, LED2, LED3, LED4, LED5, LED6, LED7
};
int LEVEL[] = {
64, 192, 320, 448, 576, 704, 832, 960
};
int fsrValue = analogRead( FSRPin );
for (i=0 ; i < LEDS ; i++) {
if ( fsrValue > LEVEL[ i ] ) {
digitalWrite( LED[ i ], HIGH );
} else {
digitalWrite( LED[ i ], LOW );
}
}
-
- Posts: 18
- Joined: Sat Sep 21, 2013 7:24 pm
Re: FSR and multiple LEDs
Thank you!! I will tinker with it later on today :0)
-
- Posts: 18
- Joined: Sat Sep 21, 2013 7:24 pm
Re: FSR and multiple LEDs
Laaaaa! It works! Laaaaaa!
Thank you!
Thank you!
Please be positive and constructive with your questions and comments.