Shop OBEX P1 Docs P2 Docs Learn Events
P8X32A Resistive Touch Buttons Problem — Parallax Forums

P8X32A Resistive Touch Buttons Problem

crispycretcrispycret Posts: 5
edited 2014-07-12 16:40 in Learn with BlocklyProp
This is my first elctro-device I am playing with. I have no experience in STAMP obviously but i do in C. I went through the propeller tutorials with no problem until i got to the Simple Circuts tutorial. I am having trouble programming the Resistive Touch Pad. I can set the the I/O Pin to High and Low, but only in code.


How do I detect if the Touch Pad has been, well touched.

I took a look at this page that has an example of how to use the Touch Pads but I need one in C.

http://microcontrollershop.com/product_info.php?products_id=4872

I also skimmed through the simpletools.h info page from the SimpleIDE Reference Page.

Comments

  • SawmillerSawmiller Posts: 276
    edited 2014-07-11 18:48
    here's one i'm playing with. have to dampen my finger thou
    /*
      robo lights....
     
    */
    
    #include "simpletools.h"                      // Include simple tools
    
    
    int  testbuttons();
    
    
    int i;
    volatile int temp = 0;
    
    int main()    // Main function
    {
                                                                                 
      //cog_run(&testbuttons, 40);  
                                        
      while (1)
      {
                             
        
        if(testbuttons())                  // check the buttons, if P7 is pressed, blink the lights
        {
          for(i=16;i<=23;i++)
          {
            high(i);
            pause(50);
          }
        
          for(i=23;i>=16;i--)
          {
            low(i);
            pause(50);
          }
          pause(100); 
        } 
        temp = 0;
                  
      }    
                 
    }
    
    int testbuttons()      // test the 7 button on quickstart board
    {
       
      high(7);
      reverse(7);  
      if(input(7)== 0)
        temp = 1;
        return temp;
    }
    
    hope it helps
    dan
  • jazzedjazzed Posts: 11,803
    edited 2014-07-11 18:59
    The preferred way to read the touch buttons is with getButtons() in the SimpleIDE workspace folder file:

    ~Documents\SimpleIDE\Propeller GCC Demos\QuickStart\Whack-a-mole\qswam.c
    /*
     * Get all buttons at once
     * Run this function from HUB if compiled for LMM.
     */
    int getButtons()
    {
        int n = 16;
        int result  = -1;
        int reading =  0;
        int pins = 0xFF;
        OUTA |= pins;               //output high to buttons
    
    
        while(n--)
        {
            DIRA |= pins;           //output high to buttons
            DIRA ^= pins;           //switch to input
            reading = pins;
            msleep(2);              //wait for RC time pause(2) using simpletools.h
            reading &= INA;          //return button states
            result  &= reading;
        }
        result = ~result & 0xFF;
        return result;
    }
    
    
    

    Still, "finger licking good" works best.
  • SawmillerSawmiller Posts: 276
    edited 2014-07-12 08:43
    Hey those look like spin!
    Great, didn't know I could use those.
    I do need a reference manual on all these commands
    Dan
  • SawmillerSawmiller Posts: 276
    edited 2014-07-12 14:23
    ok on my first code up there " robo lights" if you insert a pause(10); in the testbuttons() function right after reverse(7);
    it will work with a ordinary finger. i guess the time lets the voltage die off a little.
    anyways, fun playing with .
    dan
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-07-12 16:40
    have to dampen my finger thou
    Works without doing this for me. If I dampen my finger the LED seems to stay on.
Sign In or Register to comment.