View unanswered posts | View active topics It is currently Sat Oct 10, 2015 5:53 am

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

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

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
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 620
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.

#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
      nxtDisplayTextLine(1, "Btn 1:");  //display if not pressed

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

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

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

Timothy Friez
ROBOTC Developer - SW Engineer

Fri Oct 24, 2008 2:34 pm

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
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.