ROBOTC.net forumshttp://robotc.net/forums/ RobotC Curriculumhttp://robotc.net/forums/viewtopic.php?f=55&t=8994 Page 1 of 1

 Author: ThisGuy [ Mon Jun 23, 2014 3:40 pm ] Post subject: RobotC Curriculum Just after the first block on the second sentrybot exercise, my ultrasonic sensor starts reading-1. Is it a bug? If it is, how should I fix it?

 Author: parkway [ Tue Jun 24, 2014 8:30 am ] Post subject: Re: RobotC Curriculum Hello,Which curriculum are you working on (Lego or VEX), and what specific challenge are you trying to solve? Thanks,

 Author: ThisGuy [ Tue Jun 24, 2014 3:33 pm ] Post subject: Re: RobotC Curriculum Lego, and it is SentryBot 2 over on the sensing tab.Thank ya.

 Author: parkway [ Thu Jun 26, 2014 8:26 am ] Post subject: Re: RobotC Curriculum Use the code tags and post your code. I will attempt to replicate what your seeing and give some feedback. Thanks,

 Author: ThisGuy [ Thu Jun 26, 2014 3:36 pm ] Post subject: Re: RobotC Curriculum I know I may sound stupid now, but what is a code tag? Thanks for you patience.

Author:  JohnWatson [ Thu Jun 26, 2014 3:44 pm ]
Post subject:  Re: RobotC Curriculum

No problem, there is no such thing as a stupid question! The code tag is a tag used on the forums to format text into a 'code' block. You can create a set of code tags by clicking the 'Code' box at the top of the message body field. It will put in a [*code] and [*/code] block (without the asterisks), which is where you'll want to copy your code into. Example:

Normal, non-formatted code:

{
wait1Msec(2000);
int degrees = 90; // 'degrees' is how many degrees we want to turn

int goal = (SensorValue[compassSensor] + degrees) % 360; // 'goal' is be the current compassSensor reading + our turning degrees
/* We have to use modulus 360 to keep our goal within the bounds */
/* of the compassSensor (1 to 360 degrees, 0 is 360). */

while(SensorValue[compassSensor] != goal) // while the compassSensor sensor reading is not yet our goal:
{
// turn RIGHT in place (point turn):
motor[rightMotor] = -15; // set port2 to speed -15
motor[leftMotor] = 15; // set port3 to speed 15
}
// stop the robot:
motor[rightMotor] = 0; // set port2 to speed 0
motor[leftMotor] = 0; // set port3 to speed 0
}

Code tag formatted code:
 Code:task main(){  wait1Msec(2000);  int degrees = 90;                     // 'degrees' is how many degrees we want to turn  int goal = (SensorValue[compassSensor] + degrees) % 360;  // 'goal' is be the current compassSensor reading + our turning degrees                                                      /* We have to use modulus 360 to keep our goal within the bounds   */                                                      /* of the compassSensor (1 to 360 degrees, 0 is 360).                    */  while(SensorValue[compassSensor] != goal)   // while the compassSensor sensor reading is not yet our goal:  {                              // turn RIGHT in place (point turn):    motor[rightMotor] = -15;              // set port2 to speed -15    motor[leftMotor]  = 15;               // set port3 to speed 15  }                                        // stop the robot:  motor[rightMotor] = 0;                // set port2 to speed 0  motor[leftMotor]  = 0;                // set port3 to speed 0}

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