13
CSC 110 - Intro. to Computing Lecture 16: Robotran

CSC 110 - Intro. to Computing Lecture 16: Robotran

Embed Size (px)

Citation preview

Page 1: CSC 110 - Intro. to Computing Lecture 16: Robotran

CSC 110 -Intro. to Computing

Lecture 16:

Robotran

Page 2: CSC 110 - Intro. to Computing Lecture 16: Robotran

Announcements

Homework #4 handed out todayDue next Monday at 5PMQuiz #4 will be in 1 week

Service learning logs due todayE-mail me logs written since last deadlineThese are not graded, you get full credit given

for logs showing you visited a site

Page 3: CSC 110 - Intro. to Computing Lecture 16: Robotran

Robotran

Robotran language is very similar to PalgoBut Robotran can program Lego robots

We will (briefly) discuss some of these differencesPlaying with the robots is more fun then

listening to mePlease ask questions – it is more important you

understand this material

Page 4: CSC 110 - Intro. to Computing Lecture 16: Robotran

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

Page 5: CSC 110 - Intro. to Computing Lecture 16: Robotran

Variables in Robotran

Create a variable using var commandOptionally provide variable’s initial valuevar anglevar nameAndInitialValue = 20

Assign value to variable using letVariable must have been created beforelet angle = 54let valueUp = valueUp + 1let dist = 45 * angle - valueUp

Page 6: CSC 110 - Intro. to Computing Lecture 16: Robotran

Special Variables

randomValue is a whole number from 0 – 99,

but this value changes each timelet d = random / 100

S1 (left bumper), S2 (right bumper)Contains 1 if bumper was hit, 0 otherwiseif S1 == 1 thenlet f = S2 * 50 + 10

Page 7: CSC 110 - Intro. to Computing Lecture 16: Robotran

Loops

Robotran’s loops are identical to Palgorepeat x timesrepeat 5 times -or- repeat var times

while testwhile S1 != 0 -or- while true

for var = y to zfor i = 1 to 4 -or- for j = 0 to random

If-then-else is also identical to Palgo

Page 8: CSC 110 - Intro. to Computing Lecture 16: Robotran

Moving The Robot

To have the robot go forwardgo forward (goes forward until stopped)go forward 1 secondgo forward 87239239 inches

To have the robot go in reverse:go backward (moves until stopped)go backward 12 inchesgo backward 10 seconds

Page 9: CSC 110 - Intro. to Computing Lecture 16: Robotran

Other options

Stop the robotstop

Tell the robot to make a noisebeep

Stop performing the last line if you hit somethingcontinue until bump

Page 10: CSC 110 - Intro. to Computing Lecture 16: Robotran

Turning the Robot

Turning for some amount of timemotor A go forward 10 secondsmotor B go forward 1 second

Turn to the right (left is similar)turn rightturn right 45 degreesturn sharp left makes a tighter turn

Page 11: CSC 110 - Intro. to Computing Lecture 16: Robotran

Drawing with Robotran

Like Palgo, we can draw with RobotranLess colors and options then Palgo, but more

satisfying To have the robot start drawing

pen down To have the robot stop drawing

pen up

Page 12: CSC 110 - Intro. to Computing Lecture 16: Robotran

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

Page 13: CSC 110 - Intro. to Computing Lecture 16: Robotran

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