I'm working on a project where I have 3 FSR's(Force sensing resistors) as my inputs and I want each FSR to control 4 LED's. Basically the more force applied to the FSR, the more LED's turn on, i.e most force = 4/4 LED's on. However i want the First LED to always be on.
I've managed to code 1 FSR to work with 4 LED's and give the required result, but I'm not sure how to code in the other 2 to work with my Arduino UNO.
Here's the code for the 1 FSR that worked.
int fsr = A0;
int LED1 = 12;
int LED2 = 11;
int LED3 = 10;
int LED4 = 9;
int fsrread;
void setup(void){
Serial.begin(9600);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
}
void loop(void){
fsrread = analogRead(fsr);
Serial.println(fsrread);
if(fsrread > 200){
digitalWrite(LED2, HIGH);}
else digitalWrite(LED2, LOW);
if(fsrread > 400){
digitalWrite(LED3, HIGH);}
else digitalWrite(LED3, LOW);
if(fsrread > 800){
digitalWrite(LED4, HIGH);}
else digitalWrite(LED4, LOW);
if(fsrread =0){
digitalWrite(LED1, HIGH);}
else digitalWrite(LED1, HIGH);
}
I've looked into other forums and other sources and can't seem to find the solution. I was wondering whether this can only be done with an arduino MEGA, but wanted to be sure before I buy it.
Any help will be extremely appreciated.
P.S. I am extremely new to programming so may not be familiar with certain concepts, so elaboration would help a lot.
Thanks.