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

RobotC 3.x touch
http://robotc.net/forums/viewtopic.php?f=1&t=4553
Page 1 of 1

Author:  balu2012 [ Thu May 17, 2012 3:40 pm ]
Post subject:  RobotC 3.x touch

Hello

I´ve got a problem. Robotc and Tetrix

*Warning*:Mismatched typedefs. Converting typedef 'TSensorTypes' to typedef 'tSensors', value 'touch' : while could be wrong?

...
#pragma config(Sensor, S2, touch, sensorTouch)
....

Code:
task main()
{
  while(SensorValue (sensorTouch) == 1)    // While the Touch Sensor is active (pressed):
  {
  StartTask(fronthoch);
  StartTask(frontherab);
  }
}


Where is the Mistake?

Thanks a lot

Author:  mightor [ Thu May 17, 2012 3:47 pm ]
Post subject:  Re: RobotC 3.x touch

Try this:
Code:
task main()
{
  while(SensorValue [sensorTouch] == 1)    // While the Touch Sensor is active (pressed):
  {
    do_something();
  }
}

Btw, I am not sure what you intend to do with those tasks but you're not using them right. Try using them as functions instead. When you've mastered ROBOTC a bit more, you can progress to tasks.

- Xander

Author:  balu2012 [ Thu May 17, 2012 4:26 pm ]
Post subject:  Re: RobotC 3.x touch

Thanks a lot.

Its a Robot Arm with 4 Servos. when the sensor is pressed, i want the poor to raise

Here the complete code:
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Sensor, S2,  touch,  sensorTouch)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, openLoop)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_2,    servo2,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_3,    servo3,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_4,    servo4,               tServoStandard)

//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task fronthoch()
{
    int delta = 2;
  servoChangeRate[servo3] = delta;
  servoChangeRate[servo4] = delta;
  servo[servo3] = 255;
  servo[servo4] = 255;
}

task frontherab()
{
  int delta = 2;
  servoChangeRate[servo3] = delta;
  servoChangeRate[servo4] = delta;
  servo[servo3] = 0;
  servo[servo4] = 0;
}

task main()
{
  while(SensorValue (sensorTouch) == 1)    // While the Touch Sensor is active (pressed):
  {
  StartTask(fronthoch);
  StartTask(frontherab);
  }
}

Author:  balu2012 [ Thu May 17, 2012 4:45 pm ]
Post subject:  Re: RobotC 3.x touch

Hi

I found it. a bug in #pragma config(Sensor, S2, touchSensor, sensorTouch)

The Programm gives out only #pragma config....,.., touch.......

Now I made:
(not the whole code)

Code:
task main()
{
  while(SensorValue(touchSensor) == 0)
  {
    //leer
  }
  if (SensorValue(touchSensor) == 1)
  {
  StartTask(fronthoch);
  StartTask(frontherab);
  }
}



Thank you for your Answer

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