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

Touch sensor not working
http://robotc.net/forums/viewtopic.php?f=1&t=9146
Page 1 of 1

Author:  NoahHuppert [ Sun Jul 27, 2014 5:28 pm ]
Post subject:  Touch sensor not working

I am attempting to create a very simple program. In this program the robot will move forward until the touch sensor is hit.

Code:
#pragma config(Sensor, S2,     touchSensor,    sensorTouch)

void setMotors(int a, int b){
    motor[motorA] = a;
    motor[motorB] = b;
}

task main(){
    wait1Msec(100);//Wait for sensor to init
   
    setMotors(50, 50);

    while(sensorValue(touchSensor) == 0){
        //Do Nothing
    }

    setMotors(0, 0);
}


This code should make the robot move forward until the touch sensor is triggered.
Whenever I try and do anything with the touch sensor it does not work. When I output the value to the debug log it shows 180 when pressed and 1024 when released. I have verified that it is working normally by viewing the value on the brick itself.

Robot C Version: 4.0


Edit:
Put ending "}" for task main

Author:  Bichon [ Mon Jul 28, 2014 7:58 am ]
Post subject:  Re: Touch sensor not working

It may depend on what brick and what touch sensor you use. I had same problem with EV3 and RCX touch sensor. It seems that the resistance values are not not the same for RCX/NXT/EV3 touch sensors.

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