hi , thanks for support,
my project is about glove assessment for 2 finger with record of their flexion angle for one day(the record will be on micro SD card on shield), in this project user is able to switch between sensor 1 and 2 which are fixed on his fingers to see the progress done to reach the angle needed ,flag is given by led which blinks incrementally one by one(led 4-13) , also.individuation is calculated the difference between reading values of the 2 sensor and flag in 4 led (led 0-3).
so what i need to do is just selection of sensor by switch which doesn't block any sensor from reading its values but just to assign the led bar to one of those 2 sensors.
int flex1Pin1 = 0;
int flex2Pin2 = 1;
void setup() {
Serial.begin(9600);
for (int i=0; i<14; i++){
pinMode(i, OUTPUT); //sets the led pins 4 to 13 to output
}
}
void loop(){
int flex1Reading = analogRead(flex1Pin1);
int flex2Reading = analogRead(flex2Pin2);
Serial.println(flex1Reading);
Serial.println(flex2Reading);
int flexn0to100 = map(flex1Reading, 490, 310, 0, 100);
int flexnn0to100 = map(flex2Reading, 490, 310, 0, 100);
Serial.println(flexn0to100);
Serial.println(flexnn0to100);
int difference = abs(flexn0to100 - flexnn0to100);//define comparing
delay(250);
//Ensure to turn off ALL LEDs before continuing
for (int i=0; i<14; i++){
digitalWrite(i, LOW);
//compare values of flexn and flexnn.
if (difference < 10)
{
digitalWrite(0, HIGH);
}
else if (difference < 20)
{
digitalWrite(1, HIGH);
}
else if (difference < 30)
{
digitalWrite(2, HIGH);
}
else if (difference < 40)
{
digitalWrite(3, HIGH);
}
else
{
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
}
}
/* Read the flex Level
Adjust the value 0 to 100 to span 4 to 13
The values 130 and 275 may need to be widened to suit
the minimum and maximum flex levels being read by the
Analog pin */
int flexoReading = map(flexn0to100, 0, 100, 4, 13);
// Make sure the value does not go beyond 4 or 13
int LEDnum = constrain(flexoReading, 4, 13);
/*Call the blink function: this will turn the LED on for 10 milliseconds, and keep it
off for only 1 millisecond. You can change the blink rate by changing these values,
however, I want a quick response time when the flex sensor bends, hence the small
values. LEDnum determines which LED gets turned on.*/
blink(LEDnum, 19,1);
}
// The blink function - used to turn the LEDs on and off
void blink (int LEDPin, int onTime, int offTime)
{
// Turn the LED on
digitalWrite(LEDPin, HIGH);
// Delay so that you can see the LED go On.
delay(onTime);
// Turn the LED Off
digitalWrite(LEDPin, LOW);
// Increase this Delay if you want to see an actual blinking effect.
delay(offTime);
}
in my code i achieved the individuation (difference btw 2 sensors) and reading and assigning one sensor to led bar.