Learning Outcomes Understand While Loop Program Edison to move in any direction
Activity 1 – Drive in square shape
EdPy (Edison and Python) It’s a high level language was first released in 1991. http://www.edpyapp.com/
While Loop Loop : is to repeat the process over and over again While represent an infinite loop.
Activity 4 – Page 48 The program will repeat forever since you used a while loop and made the condition true.
Activity 5 – Page 49 #-------------Setup---------------- import Ed Ed.EdisonVersion = Ed.V2 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM #--------Your code below----------- while True: Ed.PlayBeep() # Beep Ed.LeftLed(Ed.ON) # Turn the left LED ON Ed.RightLed(Ed.ON) # Turn the right LED ON Ed.TimeWait(1, Ed.TIME_SECONDS) # Wait for 1 seconds Ed.LeftLed(Ed.OFF) # Turn the left LED OFF Ed.RightLed(Ed.OFF) # Turn the right LED OFF
Edison Drive System The drive system used by Edison is : Differential drive This drive allows Edison to move in any direction In EdPy there is a function called Ed.drive which lets you control both motors
What are Functions Direction ( Forward – Backward – Stop) Functions are pieces of code that perform a certain task depending on one of the following input Direction ( Forward – Backward – Stop) Speed ( 1-10) Distance (Ed.CM – Ed.INCH – Ed.TIME)
Activity 5– Page 52 #-------------Setup---------------- import Ed Ed.EdisonVersion = Ed.V2 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM #--------Your code below----------- # Drive the left motor forward at half of the speed for unlimited distance Ed.DriveLeftMotor(Ed.FORWARD, Ed.SPEED_5, Ed.DISTANCE_UNLIMITED) # Drive the right motor forward at half of the speed for unlimited distance Ed.DriveRightMotor(Ed.FORWARD, Ed.SPEED_5, Ed.DISTANCE_UNLIMITED) # Wait for 3 seconds Ed.TimeWait(3, Ed.TIME_SECONDS) Program Edison to move 3 seconds at speed =5. turn both motors at the same time
Activity 6– Page 53 #-------------Setup---------------- import Ed Ed.EdisonVersion = Ed.V2 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM #--------Your code below----------- Ed.DriveLeftMotor(Ed.BACKWARD, Ed.SPEED_8, Ed.DISTANCE_UNLIMITED) Ed.DriveRightMotor(Ed.BACKWARD, Ed.SPEED_8, Ed.DISTANCE_UNLIMITED) Ed.TimeWait(4, Ed.TIME_SECONDS) Program Edison to move 3 seconds at speed =5. turn both motors at the same time
Be Fast and Program First to be a winner Program Edison to beep and turn both LEDs ON for 1 seconds and then to move 3 seconds at speed =4. turn both motors at the same time
Turning Edison using Angle First, make the speed of the motors different from each other, based on which direction you want Edison to turn. Then, control the timing of the rotation until you get the angle you need. It is important to note that the timing values depend on: the speed of the motors. the surface on which the robot is driving. the battery life.
Activity 7– Page 55 #-------------Setup---------------- import Ed Ed.EdisonVersion = Ed.V2 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM #--------Your code below----------- Ed.DriveLeftMotor(Ed.FORWARD, Ed.SPEED_6, Ed.DISTANCE_UNLIMITED) Ed.DriveRightMotor(Ed.STOP, Ed.SPEED_8, Ed.DISTANCE_UNLIMITED) Ed.TimeWait(800, Ed.TIME_MILLISECONDS)
Activity 8– Page 56
Activity 9– Page 56 #-------------Setup---------------- import Ed Ed.EdisonVersion = Ed.V2 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM #--------Your code below----------- # Drive both motors forward at a speed of 9 for 30 centimetres Ed.Drive (Ed.FORWARD, Ed.SPEED_9, 30)
End-of-unit Assessment