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

My robot is fidgeting.
http://robotc.net/forums/viewtopic.php?f=11&t=5219
Page 1 of 1

Author:  artli_cheese [ Wed Dec 05, 2012 12:52 pm ]
Post subject:  My robot is fidgeting.

I have a basic vex robot with two ultrasonic sensors on front and back. Two motors that control 2 wheels each. I'm running this program
Code:
#pragma config(ProgramType, NonCompetition)
#pragma config(Sensor, in1,    Ultrasonic,     sensorSONAR, int1)
#pragma config(Sensor, in3,    backside,       sensorSONAR, int2)
#pragma config(Sensor, in5,    touchSensor,    sensorTouch)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
int speed = 225;
   //bMotorReflected[port2]=true;
   //bMotorReflected[port3]=true;
      
while(true)
   {
      
   
      if(SensorValue(Ultrasonic) > 8)
         {

               motor[port1] = -speed;
               motor[port2] = -speed;
         }
      else
      {
         bool back = (SensorValue[backside]<8);
         motor[port1] =speed;
         motor[port2] =-speed;
         Sleep(1660);
         bool right = (SensorValue[backside]>8);
         bool left = (SensorValue[Ultrasonic]>8);
         motor[port1] =-speed;
         motor[port2] =speed;
         Sleep(1660);
         if(right)
         {
            motor[port1] = speed;
            motor[port2] = speed;
            Sleep(2500);
            motor[port1] = -speed;
            motor[port2] = 0;
            Sleep(2600);
         }
         else if(left)
         {
            motor[port1] = speed;
            motor[port2] = speed;
            Sleep(2500);
            motor[port1] = 0;
            motor[port2] = -speed;
            Sleep(2600);
         }
         else if(back)
         {
            StopAllTasks();
         }
         else
         {
            motor[port1] =-speed;
            motor[port2] =speed;
            Sleep(3320);
            StopAllTasks();
         }
      }
         
      if(SensorValue[touchSensor]!=0)
      {
         StopAllTasks();
      }
      StopAllTasks();
   }
}


but somehow it starts fidgeting and does not do the actual program.
What is the problem?

Author:  artli_cheese [ Wed Dec 05, 2012 12:53 pm ]
Post subject:  Re: My robot is fidgeting.

Oh it is a microcontroller pic 0.5v

Author:  RoboDesigners [ Sat Dec 29, 2012 11:43 pm ]
Post subject:  Re: My robot is fidgeting.

Define fidget.

Author:  magicode [ Sun Dec 30, 2012 12:57 am ]
Post subject:  Re: My robot is fidgeting.

Well, you stop all tasks every time in the while loop. I'm not sure how your code does anything at all.

Author:  artli_cheese [ Tue Jan 01, 2013 5:36 pm ]
Post subject:  Re: My robot is fidgeting.

I figured it out. I changed the battery and now my code works properly.

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