Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

45
robofest 2005 robofest 2005 Introduction to Introduction to Programming Programming RIS 2.0 RCX Code RIS 2.0 RCX Code

Transcript of Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

Page 1: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Introduction to Introduction to ProgrammingProgramming

RIS 2.0 RCX Code RIS 2.0 RCX Code

Page 2: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Starting the RCX Programming Starting the RCX Programming EnvironmentEnvironment

Double Click on the RCX iconDouble Click on the RCX icon Once the program is loaded, create a Once the program is loaded, create a

new user, or select an existing onenew user, or select an existing one Click on “Program”Click on “Program” Click on “Freestyle”Click on “Freestyle”

Page 3: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Starting the RCX Programming Starting the RCX Programming EnvironmentEnvironment

Page 4: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 1: Drive Forward (with Mission 1: Drive Forward (with Timer)Timer)

Go Forward for 5 secondsGo Forward for 5 seconds StopStop

Page 5: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Page 6: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Saving your workSaving your work

Go to FileGo to File Click on SaveClick on Save Type in File Name. i.e. “First Mission”Type in File Name. i.e. “First Mission”

Page 7: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Downloading and RunningDownloading and Running 5 different programs can be loaded onto the RCX at 5 different programs can be loaded onto the RCX at

onceonce Select which slot you want to use by clicking on Select which slot you want to use by clicking on

“Settings” and selecting one of the 5 slots“Settings” and selecting one of the 5 slots Make sure that the robot’s IR port is facing towards Make sure that the robot’s IR port is facing towards

the IR tower, and click “Download”the IR tower, and click “Download” When the download is finished, you will hear a beepWhen the download is finished, you will hear a beep You can now run the program by pressing the grey You can now run the program by pressing the grey

“Prgm” button on the RCX to select the slot you “Prgm” button on the RCX to select the slot you programmedprogrammed

And press the green “Run” buttonAnd press the green “Run” button

Page 8: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Driving in ReverseDriving in Reverse Use the “Set Direction” block Use the “Set Direction” block

under “Small Blocks”under “Small Blocks”

Page 9: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Page 10: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

After changing the directions, turn on the After changing the directions, turn on the motors for 3 secondsmotors for 3 seconds

Page 11: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

TurningTurning Set the direction of one motor to “Forward” and Set the direction of one motor to “Forward” and

the direction of the other motor to “Back”the direction of the other motor to “Back”

Page 12: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Repeat ForRepeat For

Play a beep 3 timesPlay a beep 3 times

Uses the “Repeat For” block. Uses the “Repeat For” block. ““Repeat For” specifies the number of Repeat For” specifies the number of

times a certain action is to be times a certain action is to be performed.performed.

i.e. Repeat Beep For 3 Timesi.e. Repeat Beep For 3 Times

Page 13: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Repeat ForRepeat For

Page 14: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Light SensorLight Sensor• Mounted to the front of the robot, facing the ground

• Allows detection of lines, white or black, as well as

detecting lamps, lasers, and other light sources

• Use the “View” button on the robot to view the light sensor value over the black line. Remember or write down this value.

Page 15: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Using the light sensorUsing the light sensor

Select “Wait Until” from the “Wait” Select “Wait Until” from the “Wait” columncolumn

Select “Light” and click “Next”Select “Light” and click “Next” Select Input Port # to which the light Select Input Port # to which the light

sensor is connected. Press “Next”.sensor is connected. Press “Next”. Select “Bright” if looking for white Select “Bright” if looking for white

line, “Dark” if looking for black line. line, “Dark” if looking for black line. Press “Next”.Press “Next”.

Page 16: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Click on “Manual” and enter a value for the line. Usually it’s Click on “Manual” and enter a value for the line. Usually it’s the value from using the “View” button – 5 for a white line, or the value from using the “View” button – 5 for a white line, or the value from using the “View” button + 5 for a black line the value from using the “View” button + 5 for a black line

Page 17: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 2: Detect EdgeMission 2: Detect Edge

When the light sensor detects an When the light sensor detects an edge, beep three timesedge, beep three times

Page 18: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Page 19: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 3: Detect Light and Mission 3: Detect Light and BeepBeep

When the light sensor detects a When the light sensor detects a bright light source, beepbright light source, beep

Repeat foreverRepeat forever

Page 20: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Page 21: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 4: Drive Forward and Mission 4: Drive Forward and StopStop

Go forward until the edge of the Go forward until the edge of the board/tableboard/table

StopStop

Page 22: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 4 Solution

Page 23: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Touch SensorTouch Sensor

Touch sensor is Touch sensor is attached to the bumperattached to the bumper

When the bumper is When the bumper is pressed the touch pressed the touch sensor is activatedsensor is activated

Page 24: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Using the Touch SensorUsing the Touch Sensor Turn on the motorsTurn on the motors Select the “Wait Until” block from Select the “Wait Until” block from

the “Wait” column or “Repeat Until” the “Wait” column or “Repeat Until” from the ”Repeat” columnfrom the ”Repeat” column

Make sure “Touch” is selected and Make sure “Touch” is selected and press “Next”press “Next”

Choose Input Port # to which the Choose Input Port # to which the touch sensor is connected, and touch sensor is connected, and press “Next”press “Next”

Make sure “Press” is selected, Make sure “Press” is selected, which will allow the robot to react which will allow the robot to react when the touch sensor is pressed. when the touch sensor is pressed. Press “Next” again.Press “Next” again.

Press “Done”Press “Done” Turn off the motorsTurn off the motors

Page 25: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 5: Touch SensorMission 5: Touch Sensor

If the touch sensor is pressed once, turn If the touch sensor is pressed once, turn on the left motoron the left motor

If the touch sensor is pressed twice, turn If the touch sensor is pressed twice, turn off the left motor, and turn on the right off the left motor, and turn on the right motormotor

If the touch sensor is pressed three times, If the touch sensor is pressed three times, turn on both motorsturn on both motors

If the touch sensor is pressed four times If the touch sensor is pressed four times turn both motors offturn both motors off

Repeat ForeverRepeat Forever

Page 26: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Page 27: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 6: Yes or No Mission 6: Yes or No StatementsStatements

If the Light Sensor is detecting the If the Light Sensor is detecting the edge then play Beep #1edge then play Beep #1

Otherwise play Beep #2Otherwise play Beep #2 Repeat ForeverRepeat Forever

Page 28: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Page 29: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 7: Right-Handed Line Mission 7: Right-Handed Line Follow with Touch SensorFollow with Touch Sensor

If light sensor sees black - turn right, If light sensor sees black - turn right, otherwise – turn leftotherwise – turn left

Repeat the process until the bumper Repeat the process until the bumper is hitis hit

StopStop

Page 30: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 7: Right-Handed Line Follow Mission 7: Right-Handed Line Follow with Touch Sensorwith Touch Sensor

Page 31: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 8: Line Follow and Mission 8: Line Follow and StopStop

Follow the black line, until robot Follow the black line, until robot reaches edge of the boardreaches edge of the board

StopStop

Page 32: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 8: Line Follow and Mission 8: Line Follow and StopStop

Page 33: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 9: Left-Handed Line Mission 9: Left-Handed Line FollowFollow

If light sensor sees black - turn left, If light sensor sees black - turn left, otherwise – turn rightotherwise – turn right

Repeat the process until the bumper Repeat the process until the bumper is hitis hit

StopStop

Page 34: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 9: Left-Handed Line Mission 9: Left-Handed Line FollowFollow

Page 35: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 10: Sensor StackingMission 10: Sensor Stacking Stack touch sensor Stack touch sensor

on top of light on top of light sensorsensor

Follow the line, Follow the line, when touch sensor when touch sensor is activated stop.is activated stop.

When the stacked touch sensor is pressed the When the stacked touch sensor is pressed the value on Port 2 will read 100. When the touch value on Port 2 will read 100. When the touch sensor is not pressed the value for the light sensor is not pressed the value for the light sensor will be read.sensor will be read.

Page 36: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 10: Sensor StackingMission 10: Sensor Stacking

Page 37: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Sensor Stacking With TasksSensor Stacking With Tasks

Page 38: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 11: Line Counter with Mission 11: Line Counter with VariablesVariables

Go forwardGo forward Count each line as the robot crosses Count each line as the robot crosses

itit When the robot crosses the 3When the robot crosses the 3rdrd line, line,

stop.stop.

Uses variables to count number of Uses variables to count number of lineslines

Page 39: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 11: Line Counter with Mission 11: Line Counter with VariablesVariables

Page 40: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 12: Proximity Mission 12: Proximity Sensor (simple method*)Sensor (simple method*)

Use the IR Transmitter and Light Use the IR Transmitter and Light sensor to create a Proximity Sensorsensor to create a Proximity Sensor

Constantly generate IR messages, Constantly generate IR messages, and use the Light Sensor to detect and use the Light Sensor to detect the reflected IR beamthe reflected IR beam

(*) There is another better method to check fluctuations of the light intensity

Page 41: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Page 42: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Mission 13: IR Mission 13: IR CommunicationsCommunications

One RCX is sending a message, the One RCX is sending a message, the other is receiving itother is receiving it

Confirm that the message has been Confirm that the message has been received by beepingreceived by beeping

Page 43: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Transmitter Solution

Page 44: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

Receiver Solution

Page 45: Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.

robofest 2005robofest 2005

This PowerPoint will be posted online This PowerPoint will be posted online at at http://www.http://www.robofestrobofest.net/resources..net/resources.htmhtm