
Check out the eas圜 Help section for details.
#Robotc while loop code
We used them last year on our Starstruck autonomous code to stop raising our forklift to dump stuff over the fence if it had been running for more than a reasonable length of time. So What Does a Kill Timer Do?Ī kill timer allows the code to break out of a while loop if it’s been running for longer than a set amount of time, preventing gear-grinding, stalling, or tipping over. So what happens? The cortex tries to *keep* running the lift motors down anyway, for the rest of the 15-second autonomous, risking a stall if it goes on for any length of time. When it’s off-kilter, the lift cannot move downward any farther to complete the instructions of step #5. We’ve seen in our lab a few times, and at least once in competition, that when we lower the cone onto the tower, sometimes the cone is a little off-kilter and gets jammed onto the tower (instead of nesting cleanly, straight up and down). It’s in a standard sensor-based while-loop: while POT > xxx What do I mean by that? Well, step 5 uses a potentiometer (POT) on the lift to figure out how far to go up & down. Item #5 above will be our first inclusion of a kill timer. lower lift and place cone on stationary tower.back up a little and flip out claw from folding position.The pseudo-code of our In The Zone autonomous at present is like so (with forward & backward robot driving governed by ultrasonic sensor values): THEREFORE YOU NEED TO CLEAR THE TIMER BEFORE USE.ġ7 Button Pushes in 30 sec: TO MAKE A PROGRAM RUN FOR A CERTAIN AMOUNT OF TIMEI realized at our tournament yesterday that we need to add a few more steps to our autonomous program: kill timers. TIMER STARTS AS SOON AS THE PROGRAM DOES. TO MAKE A PROGRAM RUN FOR A CERTAIN AMOUNT OF TIME VOIDS JUST DO STUFF/ INT BELOW RETURNS A VALUE TO TASK MAIN. YOU CAN USE *PARAMETERS* TO SEND VALUES LIKE MOTOR SPEED OR SERVO POSITION FUNCTIONS THAT ARE SIMILAR LIKE FORWARD SLOW AND FORWARD FAST, WITH NOTESġ4Functions: Make the LED light up when the bump switched is pushed, and turn off when it is not.ġ5 Advanced Functions : ADVANCED FUNCTIONS WITH NOTESġ3-3xCounterExample: Create a count based while loop that turns a motor on for 1 second, Loop forever.ġ2IfTheElseNotes: Program the green led to turn on if the bumper switch is pressed, and off if it’s released. Like a nightlight.ĩLEDBlinkTilPot2048 Program the green led to flash on and off for 2 secondsġ0BumpLightOnNoBumpLightOff: Program the green led to turn on if the bumper switch is pressed,ġ1IfThenElse: Program the green led to turn on if the bumper switch is pressed, and off if it’s released. NOTE: Refresh rate in the debugger has to be set on Pause Refresh.ħLine follower moves servo 4-1-11: move the servo to position 127 until a light object is detected, then move to position -127.ĨFlashlight light sensor: Turn the flashlight on at dark, then of at light. Motor 2 is reversed in #pragma as if in a diff drive Useful if you want a robot to drive x distance before stopping.ĦWaitforSonarThenMotorOff: Wait until object is 20 cm away and turn the motors off. Give the students the Description and /or the Psuedocode, and have them demonstrate proficiency by writing the program or making it work.ġStartStopMotors: Turn two motors in opposite directions at half power for five seconds then stop.ĢContinuous Servo: Continuously run a servo back and forth at 0.5 sec intervals until a button is pressed.ģMotor til Touch: Turn right motor On Until Touch is pressed stop right motor.ĤledTilPotValue: Turn on the green led until the potentiometer value is greater than 2048.ĥMotorTilEncoderValue: Turn on both motors until the encoder counts 480 degrees. A great way to use these would be for a quiz, or check for understanding. These programs were written by Jim and I at Albany during CTI Facilitator training as examples to be used in the classroom.
#Robotc while loop zip file
Are there any example programs in RobotC that will help me with beginning programming?ĭownload zip file with all the programs below here.Īs a matter of fact here they are! Download the zip folder for all of the programs and notes listed below.
