Download presentation
Presentation is loading. Please wait.
Published byPaul Parrish Modified over 9 years ago
1
CSC 110 - Intro. to Computing Lecture 16: Robotran
2
Announcements Homework #4 handed out today Due next Monday at 5PM Quiz #4 will be in 1 week Service learning logs due today E-mail me logs written since last deadline These are not graded, you get full credit given for logs showing you visited a site
3
Robotran Robotran language is very similar to Palgo But Robotran can program Lego robots We will (briefly) discuss some of these differences Playing with the robots is more fun then listening to me Please ask questions – it is more important you understand this material
4
Robotran Programs All Robotran programs have a name I am not sure why and what the name is does not make a difference Names do make it easier to tell programs apart Begin each file with: program ProgramName After the name we begin a normal Palgo- like program
5
Variables in Robotran Create a variable using var command Optionally provide variable’s initial value var angle var nameAndInitialValue = 20 Assign value to variable using let Variable must have been created before let angle = 54 let valueUp = valueUp + 1 let dist = 45 * angle - valueUp
6
Special Variables random Value is a whole number from 0 – 99, but this value changes each time let d = random / 100 S1 (left bumper), S2 (right bumper) Contains 1 if bumper was hit, 0 otherwise if S1 == 1 then let f = S2 * 50 + 10
7
Loops Robotran’s loops are identical to Palgo repeat x times repeat 5 times -or- repeat var times while test while S1 != 0 -or- while true for var = y to z for i = 1 to 4 -or- for j = 0 to random If-then-else is also identical to Palgo
8
Moving The Robot To have the robot go forward go forward (goes forward until stopped) go forward 1 second go forward 87239239 inches To have the robot go in reverse: go backward (moves until stopped) go backward 12 inches go backward 10 seconds
9
Other options Stop the robot stop Tell the robot to make a noise beep Stop performing the last line if you hit something continue until bump
10
Turning the Robot Turning for some amount of time motor A go forward 10 seconds motor B go forward 1 second Turn to the right (left is similar) turn right turn right 45 degrees turn sharp left makes a tighter turn
11
Drawing with Robotran Like Palgo, we can draw with Robotran Less colors and options then Palgo, but more satisfying To have the robot start drawing pen down To have the robot stop drawing pen up
12
Your Turn Now even I’m tired of me speaking. Time to play with the robots! Ideas for projects for the lecture: Write the digits 0 – 9 Write the letters in someone’s name Draw a flower Write a program to make robot send an SOS when it gets bumped Write program to have robot get around an obstacle
13
For Next Lecture Start reading Robotran handout E-mail me your new service learning logs Get ready for homework #4 So ask me any Palgo questions you still have
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.