Exercise 10 - Connecting a force sensitive resistor
1. INTRODUCTION
A force sensitive resistor is a sensor that changes its resistor in function of force that it receives. Force sensitive resistor behaviour its similar to a potentiometer.
2. HOW TO CONNECT?
Materials:
· Arduino UNO board
· Protoboard
· Some wire Jumpers
· Force sensitive resistor
· LED
· 220 ohms resistor
· 10K ohms resistor
This sensor should be connected like a potentiometer directly on a protoboard. Furthermore, this exercise also uses a LED to test the sensor. The schematic is the same that on CONNECTING_A_POTENTIOMETER with the potentiometer.
EXERCISE_A (Testing the sensor)
|
3. PROGRAMMING
EXERCISE_A (Testing the sensor)
This program displays force sensor read value in serial monitor and in a LED. First, it declares the sensor and LED variables as INPUT, OUTPUT respectively, and starts the serial communication.
int force=A0;
int led=9;
int value=0;
void setup(){
pinMode(A0,INPUT);
pinMode(led,OUTPUT);
Serial.begin(9600);
}
On loop, value stores the read potentiometer value and convert it to a digital values with map() function.
void loop(){
value=analogRead(force);//Read sensor's pin.
value=map(value,0,1023,0,255);//Change range of values
analogWrite(led,value);//Uses PWM function in led pin.
Serial.print(value);
}