View unanswered posts | View active topics It is currently Thu Dec 18, 2014 6:08 pm






Reply to topic  [ 4 posts ] 
RobotC 3.x touch 
Author Message
Rookie

Joined: Thu May 17, 2012 3:35 pm
Posts: 36
Post 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


Thu May 17, 2012 3:40 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu May 17, 2012 3:47 pm
Profile WWW
Rookie

Joined: Thu May 17, 2012 3:35 pm
Posts: 36
Post 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);
  }
}


Thu May 17, 2012 4:26 pm
Profile
Rookie

Joined: Thu May 17, 2012 3:35 pm
Posts: 36
Post 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


Thu May 17, 2012 4:45 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.