All pastes #1267184 Raw Edit

ROBOTC Ultrasonic Turner

public c v1 · immutable
#1267184 ·published 2008-11-26 03:10 UTC
rendered paste body
#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.}}