Ed EdisonCode
L5 โ€” Light, Sound & the Robot Claw
1 / 6
Lesson 5 of 6
Light, Sound & the Robot Claw
Sensors, event-driven responses, and EdBuild physical construction
Year 9 ยท Robotics with Edisons
1Program Edison to follow a line using Ed.ReadLineState() or respond to claps using Ed.ReadClapSensor()
2Construct the EdBuild robot claw attachment and connect it to Edison's servo port
3Write a program that controls the claw servo in sequence with movement commands
Prior Knowledge: Lessons 1โ€“4 โ€” movement, loops, obstacle detection, while True. Students should be confident with EdPy download process.
Prep: Distribute EdBuild claw kits and printed instructions (EdBuild EdRoboClaw Instructions.pdf from Existing Store). Print a line-following track โ€” thick black tape on white A3 paper works well. Have a small object (cotton reel, block) for claw testing.
Slide 2 / 6
Key Vocabulary
Sensor types and event-driven programming
โšซ
Line Tracking Sensor
Two IR sensors on Edison's underside that detect whether they are above a dark or light surface. Returns LINE_ON_LEFT, LINE_ON_RIGHT, or LINE_ON_NEITHER.
๐Ÿ‘
Clap Sensor
Edison's built-in sound sensor detects sudden loud sounds (claps). Activated with Ed.ReadClapSensor(Ed.CLAP_SENSOR_ON). Returns Ed.CLAP_DETECTED.
๐Ÿฆพ
EdBuild / Servo
EdBuild is Edison's LEGO-compatible construction system. The robot claw uses a servo motor โ€” a motor that moves to a specific position (0โ€“100). Controlled with Ed.SetServoPosition().
โšก
Event-Driven Programming
Code that responds to events (sensor readings, inputs) rather than just running sequentially. The while True + sensor check pattern is a simple form of event-driven programming.
Slide 3 / 6
Line Following & Clap Detection
Two sensor-response programs โ€” students choose one
ValueMeaning
Ed.LINE_ON_LEFTLeft sensor over line โ†’ turn left
Ed.LINE_ON_RIGHTRight sensor over line โ†’ turn right
Ed.LINE_ON_NEITHERBoth off line โ†’ drive straight
while True: line = Ed.ReadLineState() if line == Ed.LINE_ON_LEFT: Ed.TurnLeft(Ed.SPEED_2, Ed.TURN_SPOT) elif line == Ed.LINE_ON_RIGHT: Ed.TurnRight(Ed.SPEED_2, Ed.TURN_SPOT) else: Ed.Drive(Ed.FORWARD, Ed.SPEED_3, Ed.DISTANCE_UNLIMITED)
Note: Must enable clap sensor first with Ed.ReadClapSensor(Ed.CLAP_SENSOR_ON) before the loop.
Ed.ReadClapSensor(Ed.CLAP_SENSOR_ON) driving = False while True: if Ed.ReadClapSensor() == Ed.CLAP_DETECTED: if driving: Ed.StopDriving() driving = False else: Ed.Drive(Ed.FORWARD, Ed.SPEED_3, Ed.DISTANCE_UNLIMITED) driving = True
Boolean variable pattern: driving = False โ€” a True/False flag that tracks robot state. Important concept for the final challenge.
Slide 4 / 6
The EdBuild Robot Claw
Physical construction + servo control code
1Attach the base plate to the front underside of Edison โ€” clip into the front two locking slots
2Clip the two claw arm pieces onto the axle on the base plate โ€” one per side
3Thread the servo cable through the clip and plug into Edison's servo port (right side, 3-pin connector)
4Test the connection is firm โ€” gently tug the claw arms to ensure they do not detach
Refer to: EdBuild EdRoboClaw Instructions.pdf for detailed diagrams. Print one per pair.
import Ed Ed.EdisonVersion = Ed.V3 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM # Servo: 0 = fully closed, 100 = fully open open_pos = 100 closed_pos = 0 wait_ms = 1000 # Open claw Ed.SetServoPosition(open_pos) Ed.TimeWait(wait_ms, Ed.TIME_MILLISECONDS) # Close claw (grip) Ed.SetServoPosition(closed_pos) Ed.TimeWait(wait_ms, Ed.TIME_MILLISECONDS) Ed.PlayBeep() # signal done
Grip position: Servo position ~30โ€“40 usually gives a gentle grip. 0 is fully clenched โ€” may slip on smooth objects.
Slide 5 / 6
Student Task
Two-part challenge โ€” sensor response AND robot claw
๐Ÿฆพ
This lesson has two evidence uploads. Part A: sensor program (line follower or clap). Part B: claw sequence program. Both must be uploaded to complete the lesson.
Direct students to: student.html โ†’ L5 Light, Sound & the Robot Claw. Steps 1โ€“3.
1Step 1: Choose line follower or clap control. Code and test it. Upload code screenshot.
2Step 2: Build the EdBuild claw. Use the instructions sheet. Take a photo once built and upload it.
3Step 3: Write a sequence program: drive โ†’ open claw โ†’ wait โ†’ close claw โ†’ reverse โ†’ beep. Test on a small object. Upload claw code screenshot.
๐Ÿฅ‰ Bronze
Working sensor program (line or clap). Claw opens and closes on command.
๐Ÿฅˆ Silver
+ Combined sequence: movement + claw in one program. Named variables for all positions and timings.
๐Ÿฅ‡ Gold
+ Use obstacle sensor to trigger the grab โ€” drive until obstacle detected, then open/close claw to grab it.
Timing: Step 1 (~12 min) โ†’ Step 2 construction (~10 min) โ†’ Step 3 coding + testing (~15 min). Move construction to start of lesson if EdBuild kits are complex for your cohort.
Slide 6 / 6
Plenary
Consolidate and preview the Final Challenge
Exit Ticket โ€” Think โ†’ Pair โ†’ Share
"Name one similarity and one difference between the line follower program and the obstacle avoidance program from Lesson 4. Consider the structure of the code, not just what the robot does."
โœ… Today we covered
  • Line tracking sensor values and line follower logic
  • Clap detection and boolean state variables
  • EdBuild robot claw construction
  • Ed.SetServoPosition() for gripper control
  • Combining movement + claw in sequence
โญ Next Lesson
Lesson 6: Edison Final Challenge

Students design and build their own Edison program. They must use movement, a loop, and a condition. Ends with PDF portfolio export. Remind students to bring their ideas.
Exit ticket model answer: Similar โ€” both use while True + sensor read + if/elif/else. Different โ€” obstacle uses rear IR sensors; line uses bottom IR; obstacle reverses on detection; line steers to correct.
๐Ÿ—’ Notes โ€” Slide 1
๐Ÿ—’ Notes โ€” Slide 2
๐Ÿ—’ Notes โ€” Slide 3
๐Ÿ—’ Notes โ€” Slide 4
๐Ÿ—’ Notes โ€” Slide 5
๐Ÿ—’ Notes โ€” Slide 6