Stop at given length from the wall

From cod3v
Other languages:
English • ‎suomi


Introduction

Often it is important to stop the robot if it sees an obstacle. The ultrasonic (or infrared) sensor is a suitable tool for that.

Robot

Any robot (with tires or treads, perhaps walking robots too) will work.

Sensors

The ultrasonic (distance) sensor is used. The sensor is attached to port number 4.

Example Videos

Theory

The ultrasonic sensor is a sonar radar that works similar to that of the bats. You should check the performance of the sensor in advance, specially if it is not working properly. A hand might be a not optimal device for checking -- you should use something more solid, eg. plastic of cardboard. The maximum working distance is about 2 meters, and the smallest distance is about 10 cm.

Example Code

The code that stops the robot when in a proximity of a wall.

Exercises

  • Make the robot speed dependent on the distance to the wall, e.g. by using a formula speed = distance.
  • Use the ideas shown in previous part (Following a Line) to follow the wall at 10 cm apart.
  • Follow a line (previous part) until the robot finds a wall at 10 cm apart from the wall.
  • If you have multiple robots, make the robots follow a line and each others, not colliding with the robot in front of.
  • Use the ultrasonic sensor to listen if there is other robots using ultrasonic sensors.

Listen


This course is supported by Meet and Code. The course is made in collaboration with Robotiikka- ja tiedekasvatus ry.

MeetAndcodeLogo.png

Back to Meet and Code 2020 I: Ev3-G