ROBOTC.net forums
http://www.robotc.net/forums/

Touch sensor multiplexer
http://www.robotc.net/forums/viewtopic.php?f=52&t=850
Page 1 of 1

Author:  disposableheroes2 [ Fri Oct 24, 2008 11:39 am ]
Post subject:  Touch sensor multiplexer

I just want to know how to get the values from the touch sensor multiplexer

Author:  Jeff McBride [ Fri Oct 24, 2008 12:17 pm ]
Post subject:  Re: Touch sensor multiplexer

There is a Touch_Mux.c sample file in the Sample Programs/FTC Training Programs/ folder.

Author:  tfriez [ Fri Oct 24, 2008 2:34 pm ]
Post subject:  Re: Touch sensor multiplexer

Touch Mux Sample Program.

1. Define the names for the bit-map buttons.
2. Do a logical "and" to check to see if each button is pressed.

Code:
#pragma config(Sensor, S1,     touchmux1,           sensorHiTechnicTouchMux)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//Bit map definitions
#define mux_button1 0x01
#define mux_button2 0x02
#define mux_button3 0x04
#define mux_button4 0x08

task main()
{
  nxtDisplayTextLine(0, "Touch MUX: Port 1");  //Display Title Text on LCD

  while(1) //Loop Forever
  {
    //Series of 4 "if" statements
    //The '&' symbol is a "logical and" used to read the bit-map from the
    //touch multiplexer.

    if(SensorValue(touchmux1) & mux_button1)  //Check if pressed
      nxtDisplayTextLine(1, "Btn 1: Pressed");  //Displayed if pressed
    else
      nxtDisplayTextLine(1, "Btn 1:");  //display if not pressed

    if(SensorValue(touchmux1) & mux_button2)
      nxtDisplayTextLine(2, "Btn 2: Pressed");
    else
      nxtDisplayTextLine(2, "Btn 2:");

    if(SensorValue(touchmux1) & mux_button3)
      nxtDisplayTextLine(3, "Btn 3: Pressed");
    else
      nxtDisplayTextLine(3, "Btn 3:");

    if(SensorValue(touchmux1) & mux_button4)
      nxtDisplayTextLine(4, "Btn 4: Pressed");
    else
      nxtDisplayTextLine(4, "Btn 4:");
  }
}

Author:  disposableheroes2 [ Thu Oct 30, 2008 2:59 pm ]
Post subject:  Re: Touch sensor multiplexer

thanks a lot.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/