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






Reply to topic  [ 5 posts ] 
Hey robotc sensor issue 
Author Message
Rookie

Joined: Mon Feb 27, 2012 5:26 pm
Posts: 20
Post Hey robotc sensor issue
Hey trying to get into use of Sensors for robotc and having issues to where I want the robot to move forward with both motors until the sensor detects less than 20cm in distance from it then to do an odd donut but the code after is able to run both wheels at once where the moving forward only moves the side first inline with the code.

Code:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     Sonar,          sensorSONAR)
#pragma config(Motor,  mtr_S1_C1_1,     left,          tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     right,         tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
   

   {  int distance_in_cm = 20;   // Create variable 'distance_in_cm' and initialize it to 20(cm).


  while(SensorValue[Sonar] > distance_in_cm)   /* While the Sonar Sensor readings are greater */
                                                     /* than the specified, 'distance_in_cm':       */
 motor[right]= 20;
 motor[left]= 20;
 // Motor B is run at a 75 power level
                       // Motor C is run at a 75 power level
}
  motor[left] = 0;
  motor[right] = 0;
 
    wait1Msec(1000);
 
  motor[left] =  100;
  motor[right] = -100;
  wait1Msec(2500);
 
 
  // Motor B is stopped at a 0 power level

}


Mon Feb 27, 2012 5:34 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: Hey robotc sensor issue
So what exactly is your question? Can you elaborate on what happens vs what you want to happen?

_________________
sudo rm -rf /


Mon Feb 27, 2012 5:58 pm
Profile
Rookie

Joined: Mon Feb 27, 2012 5:26 pm
Posts: 20
Post Re: Hey robotc sensor issue
Hey thanks but the robot when running the code only runs the first motor in the code sequence but want it to run both. After detecting less than 20cm it is supposed to spin in a circle to show it was less than 20cm both motors are both supposed to run and make the robot spin that part is not the issue just moving towards a wall in a straight line. So it is probably a coding issue and tried to use a sample code from robotc.


Tue Feb 28, 2012 10:06 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: Hey robotc sensor issue
I'm still having trouble understanding what you're trying to say, but does this salve your problem?
Code:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     Sonar,          sensorSONAR)
#pragma config(Motor,  mtr_S1_C1_1,     left,          tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     right,         tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
   

  int distance_in_cm = 20;   // Create variable 'distance_in_cm' and initialize it to 20(cm).


  while(SensorValue[Sonar] > distance_in_cm){   /* While the Sonar Sensor readings are greater */
                                                     /* than the specified, 'distance_in_cm':       */
 motor[right]= 20;
 motor[left]= 20;
 // Motor B is run at a 75 power level
                       // Motor C is run at a 75 power level
}
  motor[left] = 0;
  motor[right] = 0;
 
    wait1Msec(1000);
 
  motor[left] =  100;
  motor[right] = -100;
  wait1Msec(2500);
 
    motor[left] = 0;
  motor[right] = 0;
  // Motor B is stopped at a 0 power level

}

_________________
sudo rm -rf /


Tue Feb 28, 2012 2:11 pm
Profile
Rookie

Joined: Mon Feb 27, 2012 5:26 pm
Posts: 20
Post Re: Hey robotc sensor issue
Well I will try this a.s.a.p and will see from there thanks for the help and for showing me this.


Tue Feb 28, 2012 3:39 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.