Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 14

NXTG Workshop Day 2

Programming with
• Touch Sensor
• Light Sensor
• Ultrasonic Sensor

Repeat

CJ Chung
Associate Professor of Computer Science
Lawrence Technological University
Start-Touch

 Wait until the touch sensor is pressed;


 Then start the robot to go forward
 Stop after a second
Start-Light

 Locate the robot in the middle of the ring


 Wait until the light sensor detects very
bright (lantern) light
 Then start the robot to go forward
 Stop after a second
Start-Light
Stop-Touch

 Go straight until the bumper is hit


 then stop
Stop-Edge

 Go straight until the white edge of the


ring
 Then stop
Ultrasonic Sensor Test
Loop

 To repeat a sequence of code


 Until
 Elapsed time
 Number of repetitions

 Sensor condition is met

 Logic becomes true

 Forever
Say “Yes” – 10 times
Make the robot move around in the
ring – Basic Sumo (Sumo0)

 Repeat the following forever:


 Go forward until the edge
 Backward slightly

 Spin right
Sumo0
First Sumo Competition

 Some matches
 Ask students to list ideas to improve the
Sumo robot
Repeat Until

 Spin a little bit until it detects an object


less than 10 inches
 If detected, stop spinning and say
“Object”
Mission: Find a static object using the
ultrasonic sensor & push it out of the ring,

but the robot


should remain on
the ring!!

box

Robot

You might also like