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

Code for Touch Sensor

NWCCTVNWCCTV Posts: 3,629
edited 2015-06-19 18:21 in General Discussion
Does anyone know of any code that will work with this sensor: http://www.ebay.com/itm/261758997611?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT ?

I purchased a few of them since they are so cheap and have a project in mind once the rest of my parts get here but I can not get the code in the OBEX http://obex.parallax.com/object/169 to work with it. Thanks for your help.

Comments

  • rosco_pcrosco_pc Posts: 464
    edited 2015-06-18 21:33
    NWCCTV wrote: »
    ... but I can not get the code in the OBEX http://obex.parallax.com/object/169 to work with it. Thanks for your help.

    You just need to read the input pin.
    Nothing more is needed, the logic in this object is to create a capacitive sensor with only the prop.
    But in the module you bought that is handled by the touch sensor chip.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-06-18 22:02
    Not sure I understand what you are saying. The way I read it is that when I place my finger near the sensor the LED on pin 16 should light up but it does not.
  • Hal AlbachHal Albach Posts: 747
    edited 2015-06-19 06:40
    Good Morning, Andy;
    I believe what rosco_pc is trying to tell you is that you do not need a driver for this device. It senses the touch on its own and outputs a high to indicate the touch. Treat it like a push button
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-19 08:57
    Andy,

    I haven't tested this with anything but based on rosco_pc and Hal's comments I figure it should work.
    CON
    
      _clkmode = xtal1 + pll16x                           
      _xinfreq = 5_000_000
    
      TOUCH_PIN = 0
    
    OBJ
    
      Pst : "Parallax Serial Terminal"
    
    PUB Main
    
      Pst.Start(115_200)
    
      repeat
        Pst.Home
        result := ina[TOUCH_PIN]
        if result
          Pst.Str(string(11, 13, "Touched"))
        else
          Pst.Str(string(11, 13, "Not Touched"))
    
        Pst.ClearEnd
        Pst.Newline
        Pst.ClearBelow  ' clear any text below output
        waitcnt(clkfreq / 20 + cnt)
    

    Those sensors look pretty cool. It looks like you can power them with 3.3V.

    If for some reason you power them with 5V you'll need a series resistor between the sensor's output and the Propeller's I/O pin. I'd use something between 3.3k ohm and 10k ohm. Again this is only if using 5V on the sensor's VDD pin. If you use 3.3V you don't need a resistor but a 100 ohm resistor would keep the Prop safe in case there was a code error which set the I/O pin as an output.

    Edit: I had left out "+ cnt" in the waitcnt command.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-06-19 17:46
    Well, The PST shows Not Touched when I am not touching but does not show Touched when I touch it.

    EDIT: However, I was able to get it to work just like a push button. You are correct, these things are kind of cool and pretty cheap too!!!!.

    Thanks all for contributing. Now on to my project!!
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-19 18:16
    Sorry, I left out the "+ cnt" part in the waitcnt command. I just edited the earlier post. It should work now.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-06-19 18:21
    Yep. It sure does. I thank you very much. I basically just needed to get it to work as a standard push button, which from what I am reading is what it is!!
Sign In or Register to comment.