code help with a hotpot


i feel fundamental code question.
i want use hotpot (100-10kohm), pressure sensitive potentiometer, sold sparkfun led project. unlike regular pot, once take finger off hotpot it's resistance goes minimum 100ohm. can put finger on 1 spot , specific resistance or slide finger along , change resistance.

the fundamental question this: 1 use analog read read value of regular pot , store value int.

but hotpot need arduino monitor hotpot(three of them in fact) , detect when hotpot being actuated. moreover, need arduino measure in "realtime" if sliding finger along hotpot , update stored value @ reasonable rate (5hz) , detect last resistance measurement when person removes finger.

i have no idea how , appreciate help, if can done interrupts , direct c coding.

what i'v tried far awkward series of if, else statements. in main loop have analog read check pot , divide 10 values 0-1024, if greater 5 (allow jitter) write value int hotpotnew, else move on next hotpot. next  compare  hotpotnew hotpotcurrent see if greater, lesser, or equal. i've not been able make part functional since putting finger in middle of hotpot 5kohms +/- 250ohms. how 1 compare 2 values while allowing variability/error? if work, need way structure program if moving finger along hotpot arduino poll , record. if isn't touching hotpot or not moving, go on , read hotpot2 , hotpot3.
is hopelessly complex noob? , examples appreciated.



Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > code help with a hotpot


arduino

Comments