Grip Sensor
int led1 = 8;
led2 = 9;
int led3 = 10;
int led4 = 11;
int FSRanalogpin = 0;
int value;
int fsrReading;
void setup(void) {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
void loop(void){
value = analogRead(FSRanalogpin);
value = map(value, 0, 1023, 0, 500);
Serial.print("Analog reading = ");
Serial.println(value);
if (value < 10) {
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
} else if (value < 50 ) {
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
} else if (value < 95) {
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
} else if (value < 110) {
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, LOW);
} else {
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
}
delay(100); //Delay of 100 milliseconds
}
(instructions coming soon - still drafting it up)
Supplies
x1 Arduino nano
x1 FSR
a bunch of M-M / M-F jumper wires
x4 LEDs
x2 mini circuit boards
x2 330 ohm resistor