By Chang Soo Lee
This PicBasic Pro code reads a force-sensing resistor using a Voltage Divider circuit connected to an analog pin of a microcontroller.

Back to FSR Report.

'Basic serial communication 
'Send data to Processing
'by Chang Soo Lee
'ITP, NYU

define OSC 4
DEFINE  ADC_BITS        10
DEFINE  ADC_CLOCK       3
DEFINE  ADC_SAMPLEUS    50

SensorValue var word
SensorValueB var Byte

tx var portc.6
rx var portc.7

n9600 con 16468

TRISA = %11111111
ADCON1 = %10000010

Main:
    ADCin 0, SensorValue
    SensorValueB = SensorValue/4
    serout2 tx, n9600, [SensorValueB]
    pause 50
Goto main