Ed EdisonCode
L4 β€” Flowcharts & Obstacle Detection
1 / 6
Lesson 4 of 6
Flowcharts & Obstacle Detection
Designing algorithms visually, then implementing them with IR sensors
Year 9 Β· Robotics with Edisons
1Identify and correctly use the four standard flowchart symbols (terminal, process, decision, I/O)
2Draw a flowchart for an obstacle avoidance algorithm with correct branching
3Implement the algorithm in EdPy using Ed.ReadObstacleDetection() and if/elif/else
Prior Knowledge: Lessons 1–3 β€” Edison hardware, EdPy movement commands, for loops. Students should be comfortable with the download process.
Prep: Print or display a flowchart symbol reference. Have rulers and pencils ready for drawing flowcharts. Ensure there are small obstacles (books, pencil cases) for testing.
Slide 2 / 6
Key Vocabulary
Flowchart and conditional terminology
πŸ—ΊοΈ
Flowchart
A visual diagram that shows the steps of an algorithm using standard symbols connected by arrows. Flowcharts are language-independent β€” they describe WHAT the program does, not HOW it's written in code.
β—‡
Decision (Selection)
A diamond-shaped flowchart symbol that represents a YES/NO question. It always has two exit paths. In code, this becomes an if statement.
πŸ”΄
IR Obstacle Sensor
Edison's front-facing infrared sensors emit light and detect reflections. If an object is within range (~10cm), the sensor reports an obstacle. Read with Ed.ReadObstacleDetection().
πŸ”
While Loop
A loop that continues as long as a condition is true. while True: runs forever β€” perfect for a robot that should keep responding until switched off.
Slide 3 / 6
Flowchart Symbols
The four symbols every CS student must know
β¬­
Terminal
Start or End of the algorithm. Always oval/rounded rectangle.
β–­
Process
An action or instruction. e.g. "Drive Forward", "Turn Left 90Β°"
β—‡
Decision
A YES/NO question. Always two exits: Yes path and No path.
β–±
Input / Output
Data entering or leaving. e.g. "Read obstacle sensor", "Beep"
Rules students often forget: (1) Decision diamonds ALWAYS have exactly two exits labelled YES and NO. (2) All paths must eventually reach an END terminal β€” or loop back. (3) Arrows show direction of flow.
Connection to code:
Terminal β†’ start/end of program
Process β†’ a command line (e.g. Ed.Drive)
Decision β†’ if/elif/else
I/O β†’ Ed.ReadObstacleDetection() / Ed.PlayBeep()
Common exam question: Students are given code and asked to draw the corresponding flowchart β€” or vice versa. Both directions matter.
Slide 4 / 6
Obstacle Detection Code
Mapping the flowchart directly to EdPy
ValueMeaning
Ed.OBSTACLE_AHEADObject directly in front
Ed.OBSTACLE_LEFTObject on left side
Ed.OBSTACLE_RIGHTObject on right side
Ed.OBSTACLE_NONENo obstacle detected
Show this live: Hold Edison up and wave your hand in front of it. Open the EdPy serial console to see the sensor value change in real time.
import Ed Ed.EdisonVersion = Ed.V3 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM reverse_dist = 5 turn_angle = 90 speed = Ed.SPEED_3 while True: obstacle = Ed.ReadObstacleDetection() if obstacle == Ed.OBSTACLE_AHEAD: Ed.Drive(Ed.BACKWARD, Ed.SPEED_5, reverse_dist) Ed.TurnLeft(Ed.SPEED_5, turn_angle) elif obstacle == Ed.OBSTACLE_LEFT: Ed.TurnRight(Ed.SPEED_3, 45) elif obstacle == Ed.OBSTACLE_RIGHT: Ed.TurnLeft(Ed.SPEED_3, 45) else: Ed.Drive(Ed.FORWARD, speed, Ed.DISTANCE_UNLIMITED)
Slide 5 / 6
Student Task
Draw the flowchart first β€” then code it
Direct students to: student.html β†’ L4 Flowcharts & Obstacle Detection. Steps 1–3. Step 3 requires TWO uploads: flowchart photo + code screenshot.
1Step 1: Draw a flowchart for a simple obstacle avoidance algorithm (forward β†’ check β†’ reverse + turn if obstacle β†’ loop). Upload photo.
2Step 2: Study the obstacle detection values. Type and test the full program from Slide 4. Screenshot the code.
3Step 3: Draw an improved flowchart matching the full code (inc. left/right cases). Enhance the code (beep on detection + random turn). Two uploads required.
πŸ₯‰ Bronze
Correct flowchart symbols for a 2-path algorithm. Working obstacle avoidance code that reverses and turns.
πŸ₯ˆ Silver
+ Flowchart includes all 4 cases (ahead, left, right, none). Code includes beep on detection. Comments in code.
πŸ₯‡ Gold
+ Random turn direction using Ed.GetRandomNumber(1,2) β€” flowchart updated to show random branch.
Physical setup: Place a few books or pencil cases on desks as obstacles. Students test their Edison navigating around them. Clear a 60Γ—60cm area per pair minimum.
Slide 6 / 6
Plenary
Consolidate and preview Lesson 5
Exit Ticket β€” Peer Discussion (2 min)
"The else branch in our obstacle code runs Ed.Drive with Ed.DISTANCE_UNLIMITED. If we removed the while True loop, would the robot still avoid obstacles indefinitely? Why or why not?"
βœ… Today we covered
  • Four standard flowchart symbols
  • Decision diamonds β€” always two exits
  • Ed.ReadObstacleDetection() values
  • while True: for continuous behaviour
  • if / elif / else conditional logic
⏭ Next Lesson
Lesson 5: Light, Sound & the Robot Claw

Edison responds to line tracking sensors and clap detection β€” then we attach the EdBuild robot claw to combine movement and gripper control.
Exit ticket answer: Without while True, the if/elif/else only checks the sensor once. The robot would make one decision then stop β€” not continuous avoidance.
πŸ—’ Notes β€” Slide 1
πŸ—’ Notes β€” Slide 2
πŸ—’ Notes β€” Slide 3
πŸ—’ Notes β€” Slide 4
πŸ—’ Notes β€” Slide 5
πŸ—’ Notes β€” Slide 6