View unanswered posts | View active topics It is currently Wed Oct 01, 2014 2:22 pm






Reply to topic  [ 5 posts ] 
My robot is fidgeting. 
Author Message
Rookie

Joined: Wed Dec 05, 2012 11:00 am
Posts: 9
Post 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?


Wed Dec 05, 2012 12:52 pm
Profile
Rookie

Joined: Wed Dec 05, 2012 11:00 am
Posts: 9
Post Re: My robot is fidgeting.
Oh it is a microcontroller pic 0.5v


Wed Dec 05, 2012 12:53 pm
Profile
Novice
User avatar

Joined: Sat Jul 10, 2010 3:06 pm
Posts: 86
Location: Roanoke, VA
Post Re: My robot is fidgeting.
Define fidget.

_________________
Check out my website! www.RoboDesigners.com

VRC Team 2190

Twitter: @RoboDesigners


Sat Dec 29, 2012 11:43 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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.

_________________
sudo rm -rf /


Sun Dec 30, 2012 12:57 am
Profile
Rookie

Joined: Wed Dec 05, 2012 11:00 am
Posts: 9
Post Re: My robot is fidgeting.
I figured it out. I changed the battery and now my code works properly.


Tue Jan 01, 2013 5:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.