View unanswered posts | View active topics It is currently Fri Oct 30, 2020 6:42 am

Reply to topic  [ 2 posts ] 
Touch sensor not working 
Author Message

Joined: Sun Jul 27, 2014 5:20 pm
Posts: 1
Post 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.

#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

Put ending "}" for task main

Sun Jul 27, 2014 5:28 pm

Joined: Tue Feb 21, 2012 12:38 pm
Posts: 12
Location: Paris, France
Post 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.

Bichon, Brickstory team for Eurobot

Mon Jul 28, 2014 7:58 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.