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:"); } } |