I WISH I HAD SOME EXAMPLE PROGRAMS IN ROBOTC!

Problem:

Are there any example programs in RobotC that will help me with beginning programming?

reddownloadDownload zip file with all the programs below here.  

Solution:

As a matter of fact; here they are! Download the zip folder for all of the programs and notes listed below.

These programs were written by Jim and I at Albany during CTI Facilitator training as examples to be used in the classroom. A great way to use these would be for a quiz, or check for understanding. Give the students the Description and /or the Psuedocode, and have them demonstrate proficiency by writing the program or making it work.

1StartStopMotors:  Turn two motors in opposite directions at half power for five seconds then stop.

2Continuous Servo: Continuously run a servo back and forth at 0.5 sec intervals until a button is pressed.

3Motor til Touch: Turn right motor On Until Touch is pressed stop right motor.

4ledTilPotValue:  Turn on the green led until the potentiometer value is greater than 2048.

5MotorTilEncoderValue:    Turn on both motors until the encoder counts 480 degrees. Motor 2 is reversed in #pragma as if in a diff drive Useful if you want a robot to drive x distance before stopping.

6WaitforSonarThenMotorOff:  Wait until object is 20 cm away and turn the motors off. NOTE: Refresh rate in the debugger has to be set on Pause Refresh.

7Line follower moves servo 4-1-11: move the servo to position 127 until a light object is detected, then move to position -127.

8Flashlight light sensor: Turn the flashlight on at dark, then of at light. Like a nightlight.

9LEDBlinkTilPot2048 Program the green led to flash on and off for 2 seconds while the pot reads less than 2048.
10BumpLightOnNoBumpLightOff: Program the green led to turn on if the bumper switch is pressed, and off if it’s released. Loop forever.
11IfThenElse: Program the green led to turn on if the bumper switch is pressed, and off if it’s released. Loop forever.
12IfTheElseNotes: Program the green led to turn on if the bumper switch is pressed, and off if it’s released. Loop forever. WITH NOTES
13-3xCounterExample: Create a count based while loop that turns a motor on for 1 second, then off for one second. Do this five times. WITH NOTES
14Functions: Make the LED light up when the bump switched is pushed, and turn off when it is not. This is an example of a function.
15 Advanced Functions : ADVANCED FUNCTIONS -FUNCTIONS THAT ARE SIMILAR LIKE FORWARD SLOW AND FORWARD FAST, -YOU CAN USE *PARAMETERS* TO SEND VALUES LIKE MOTOR SPEED OR SERVO POSITION -VOIDS JUST DO STUFF/ INT BELOW RETURNS A VALUE TO TASK MAIN.
16  While Timer: NOTE: TO MAKE A PROGRAM RUN FOR A CERTAIN AMOUNT OF TIME TIMER STARTS AS SOON AS THE PROGRAM DOES. THEREFORE YOU NEED TO CLEAR THE TIMER BEFORE USE. THERE ARE 4 TIMERS
17 Button Pushes in 30 sec: TO MAKE A PROGRAM RUN FOR A CERTAIN AMOUNT OF TIME TIMER STARTS AS SOON AS THE PROGRAM DOES. THEREFORE YOU NEED TO CLEAR THE TIMER BEFORE USE. THERE ARE 4 TIMERS

Tags: , , , ,

Chris Hurd

I currently teach Technology and Engineering at Cazenovia HS in CNY. I also teach summers at the college level for PLTW in Oregon, Ohio, Florida, California, Kentucky, Eastern Michigan, and NY.

Get in touch

Jim Hanson

Chris Hurd

Offcanvas

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.