Re: Press Ctrl+V or Cmd+V or whatever and post
Posted by: ?????(000)
Date: 2008-11-10 11:29:27
Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.
You can join Glitch City Research Institute to ask questions or discuss current developments.
You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.
#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S3, sonar, sensorSONAR)
#pragma config(Motor, mtr_S1_C1_1, , tmotorNone, openLoop)
#pragma config(Motor, mtr_S1_C1_2, , tmotorNone, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main()
{
getJoystickSettings(joystick); //Get a packet of data from the Field Management System
while(joystick.StopPgm) //If the packet says to halt the program...
{
getJoystickSettings(joystick); //Get another packet of data. If it's not what we want
wait1Msec(50); //we'll wait for another packet.
}
bNoPowerDownOnACAdaptor = true; //If the AC adapter's connected, STOP ****ING SHUTTING OFF ON ME
int UltrasonicReading; //Create variable for sensor data.
eraseDisplay(); //Erase the display.
while (true) /* NOTE TO SELF - FIX LOOP */
{
UltrasonicReading = SensorValue[sonar]; //Store the sonar value in the variable.
nxtDisplayCenteredTextLine(1, "Value: %d", UltrasonicReading); //Display the variable on screen.
while (SensorValue[sonar] > 25) { //While the robot's sonar is NOT reading below 25...
motor[motorE] = 50; //...drive forward...
motor[motorD] = 50; //...and keep moving forward.
}
motor[motorE] = -50; //... otherwise back up...
motor[motorD] = -50;
wait1Msec(500); //... for half a second (.500 seconds)...
motor[motorE] = -50; //... and then turn around...
motor[motorD] = 50;
wait1Msec(400); //... for about .400 seconds.
}
}