c - Touch sensor not working -


I am trying to create a very simple program in RobotSee. In this program the robot will proceed until the touch sensor is killed.

  #pragma config (sensor, s2, touch sensor, sensor touch) zero setmotor (int a, int b) {motor [motor a] = a; Motor [motor b] = b; } Work Main () {wait1Msec (100); // wait for the sensor of setMotors init (50, 50); While (sensor (touchscreen) == 0) {// nothing} setmators (0, 0); }  

This code should be forwarded to the robot until the touch sensor is triggered. Whenever I try to do anything with touch sensor, it does not work. When I output output to the debug log, it shows 180 is pressed and 1024 is issued. I have verified that it is working normally on the brick by looking at the value.

Robot C Edition: 4.0

Apparently, your touch sensor is Not clear - I can get it from the document - how it can be fixed in the code, but the sensor will be clearly put in raw mode around a work (if the situation varies in the future), and then calculate the boolean Value with a function like this:

  bool sensorIsOn (Small Sensor RawValue) {bool isOn = false; If (CensorAvailability> 512) {isOn = true; } Is a return; }  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -