The exact figures will depend on your particular FSR, but typi-
cally you’ll see 100KΩ of resistance with light pressure and 1Ω
of resistance with maximum pressure. If you have a
multimeter
,
you can measure the changes in resistance to see for yourself,
or you can look at the component’s
datasheet
, which will tell you
what to expect from the sensor.
If you’re going to replace the resistor connected to 3.3V in Figure
8-7 with a variable resistor like an FSR, you’ll want the value of the
other resistor to be somewhere in between the minimum and max-
imum resistance so that you can get the most range out of the sen-
sor. For a typical FSR, try a 10KΩ resistor. To give the force-sensitive
resistor a test drive:
1. Wire up an FSR to the ADC as shown in Figure 8-8.
2. Execute the code in Example 8-1 again.
3. Watch the readings on the screen as you squeeze the FSR.
If everything is working correctly, you should see the values rise as
you increasingly squeeze harder on the FSR. As you press harder,
you’re reducing the resistance between the two leads on the FSR.
This has the effect of sending higher voltage to the analog input.
You’ll encounter many analog sensors that use this very same
principle, and a simple voltage divider circuit, along with an ana-
log-to-digital converter, will allow your Raspberry Pi to capture that
sensor data.
Analog Input and Output 137
GSW_RASPI_4ED_FIN.indd 137GSW_RASPI_4ED_FIN.indd 137 10/28/21 10:54 AM10/28/21 10:54 AM