Shop OBEX P1 Docs P2 Docs Learn Events
RCTime Touch Sensor — Parallax Forums

RCTime Touch Sensor

kelvin jameskelvin james Posts: 531
edited 2009-02-17 13:09 in Accessories
I can't remember if anyone has suggested this before, so i figured i would post it anyway. It is just a simple way to make a touch switch using the rc circuit and an additional lead.
Basically, when the sensor lead is touched, it changes the normally constant value being read by rctime from the resistor and capacitor combination. That change in value is used to trigger an event.
To get the proper resistor and cap values is from experimenting, though there is a mathematical approach explained in the rctime syntax. I used a 10nf ceramic cap, and a 47k resistor to give a fair, but not large resolution.
The sensor lead itself is a resistor with one end inserted into a piece of conductive foam. It could be just a wire by itself, or attatched to anything conductive.
The constant value of the circuit seems to drift a bit after a period of time, but if the sense threshold is kept fairly wide, it should not matter.

**

' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM1}



result  VAR     Word

Test:

  HIGH 0                                ' charge the cap
  PAUSE 1
  RCTIME 0, 1, result                   ' measure RC discharge time
  DEBUG DEC ? result                    ' display result
  PAUSE 500
  IF result > 340 OR result < 318 THEN
        DEBUG " TOUCH DETECTED ",CR
        END
  ELSE : GOTO test
  ENDIF
378 x 286 - 21K
415 x 406 - 45K

Comments

Sign In or Register to comment.