140 likes | 320 Views
Robot C. Ready, SET, Go! Workshop SDSU, Fall 2013. Programming is Fun!. Tell the Robot exactly what to do & watch it run. Be Specific! Use Loops to repeat statements. Put several actions together to make a dance! Put several Robots together and watch the patterns. How Specific?.
E N D
Robot C Ready, SET, Go! Workshop SDSU, Fall 2013
Programming is Fun! • Tell the Robot exactly what to do & watch it run. • Be Specific! • Use Loops to repeat statements. • Put several actions together to make a dance! • Put several Robots together and watch the patterns
How Specific? • Robots aren’t very smart … not nearly as smart as people. • … be VERY specific. • Direct someone to enter a room and sit down.
The ‘C’ Programming Language • Used for many low-level applications. • Is a ‘compiled’ language. • Compile for a specific Operating System, then run the program on computers using that OS. • Function named ‘main’ is first to run. • main is the ‘boss’. It’s statements happen in order when you run the program. • main tells other functions when to run.
Robot C • Robot C is a version of the C programming language. • We’ll use Robot C to program LEGO’s MindstormsRobots
Simple Moves • Download the SimpleMoves.c file and save it on your desktop. • Start ROBOTC • File / Open & Compile / Browse to the desktop and open SimpleMoves.c • Check out the code • The comments (in green) explain what’s happening • The statements (in blue & red) tell the robot what to do
Is your Robot ready to roll? • Connect the battery pack and wheel motor cables (pages 19-23). • Turn your Robot on with the orange button. • Connect your Robot to your Computer with the USB cable. • In ROBOTC, choose Robot/Compile and Download Program. • Change the Refresh setting in the debug pop-up box from ‘continuous’ to ‘paused’. • Unplug your Robot from the Computer and set it on the FLOOR! • Use the Orange button and arrow keys to find your program and run it.
Test & Debug • Change the commands in your program and repeat the steps to download and test the revised program: • Connect your Robot to your Computer with the USB cable. • In ROBOTC, choose Robot/Compile and Download Program. • Change the Refresh setting in the debug pop-up box from ‘continuous’ to ‘paused’. • Unplug your Robot from the Computer and set it on the FLOOR! • Use the Orange button and arrow keys to find your program and run it. • See if you can finish the program and get your Robot to move forward and backward and turn left and right.
Functions • Download the Functions.c file and save it on your desktop. • Start ROBOTC • File / Open & Compile / Browse to the desktop and open Functions.c • Check out the code • The comments (in green) explain what’s happening • The statements (in blue & red) tell the robot what to do • How many functions are there? • What does each function do?
Functions - too • Call the functions from main as many times as you want to move your Robot in a pattern. (You choose the pattern.) • Can we use just one function for spin left and spin right?
Loops • Download the Loops.c file and save it on your desktop. • Start ROBOTC • File / Open & Compile / Browse to the desktop and open Functions.c • Check out the code • The comments (in green) explain what’s happening • The statements (in blue & red) tell the robot what to do • Can you find the loop? • How many times does it repeat? • How does it know when to stop?
Loops - too • Can you put a loop into your functions program to repeat some function calls? • Can you use several loops to repeat different groups of function calls different numbers of times?
Let’s Dance • Can you make a dance? • Can you work with another team to have your robots do the same dance? • Can you work with several teams to do a group dance? • Can you make 2 robots dance together? (One moves forward, the other moves back, etc.)
Clean Up • Put the Robots and Books back. • Remove the cables and battery pack and put the pieces in the tray. • Plug the battery packs in to re-charge. • THANK YOU!!! • HOPE YOU HAD FUN!!!