FSR and multiple LEDs

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
shessj
 
Posts: 18
Joined: Sat Sep 21, 2013 7:24 pm

FSR and multiple LEDs

Post by shessj »

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

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: FSR and multiple LEDs

Post by adafruit_support_mike »

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:

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 );
    }
}
The technique is called 'tabular programming' since all the important information lives in the two tables.

shessj
 
Posts: 18
Joined: Sat Sep 21, 2013 7:24 pm

Re: FSR and multiple LEDs

Post by shessj »

Thank you!! I will tinker with it later on today :0)

shessj
 
Posts: 18
Joined: Sat Sep 21, 2013 7:24 pm

Re: FSR and multiple LEDs

Post by shessj »

Laaaaa! It works! Laaaaaa!

Thank you!
LEDs FSR.jpg
LEDs FSR.jpg (143.26 KiB) Viewed 1450 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”