View unanswered posts | View active topics It is currently Fri Oct 31, 2014 2:42 pm






Reply to topic  [ 4 posts ] 
Touch sensor multiplexer 
Author Message
Rookie

Joined: Fri Oct 24, 2008 11:35 am
Posts: 3
Post Touch sensor multiplexer
I just want to know how to get the values from the touch sensor multiplexer


Fri Oct 24, 2008 11:39 am
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: Touch sensor multiplexer
There is a Touch_Mux.c sample file in the Sample Programs/FTC Training Programs/ folder.

_________________
Jeff McBride
Benson Robotics Club


Fri Oct 24, 2008 12:17 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 613
Post 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:");
  }
}

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Fri Oct 24, 2008 2:34 pm
Profile
Rookie

Joined: Fri Oct 24, 2008 11:35 am
Posts: 3
Post Re: Touch sensor multiplexer
thanks a lot.


Thu Oct 30, 2008 2:59 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.