12.Force-Sensitive Resistor - Spark Core
Let’s read data sheet (PDF ). It says resistance changes 1K - 100K (roughly linear).
I used 10K ohm resistor to measure as follows.
In theory, if you touch the censor, resistor values decreases and the voltage increases. So simply read the voltage using A0.
// Force-Sensitive Resistor // #include <stdarg.h> #define PRINTF_BUFFER_SIZE 128 void Serial_printf(const char* fmt, ...) { char buff[PRINTF_BUFFER_SIZE]; va_list args; va_start(args, fmt); vsnprintf(buff, PRINTF_BUFFER_SIZE, fmt, args); va_end(args); Serial.println(buff); } void setup() { Serial.begin(9600); pinMode(A0, INPUT); } void loop() { Serial_printf("%d", analogRead(A0)); delay(400); }
It worked for me!