In a school competition for my son, he wants to make a toy car that will stop before it hits a wall (before, not making an impact). It can go as slow as it likes and cannot be remote controlled. I was thinking maybe a phototransistor on the front, shrouded so when the wall becomes close the light level would become low enough to switch and turn off the motor.

Do you think that could work? I have a feeling it is too imprecise. Can you think of a better way? It may not be approaching the wall exactly perpendicularly if the car veers off slightly.

Extra thanks for circuit diagrams - it is a very long time since I did anything like this...

  • \$\begingroup\$ Ultransonic might be easiest (assuming you have a microcontroller of some sort), HC-SR04 is cheap and easy to use. \$\endgroup\$ – Roger Rowland May 22 '15 at 8:23
  • \$\begingroup\$ Sparkfun and others sell a variety of proximity sensors, both infrared and ultrasonic. These would definitely be easier to use than making your own. \$\endgroup\$ – Nick Johnson May 22 '15 at 8:39
  • \$\begingroup\$ I think you'll find the idea doesn't work. The problem comes if the car approaches the wall at an angle. Then the shroud never becomes completely occluded. To compensate, you'd need a ring of sensors, one every few degrees. It will also obviously have problems in any area with the walls painted a dark color. \$\endgroup\$ – WhatRoughBeast May 22 '15 at 9:52


I am answering your question making these two assumptions, you have enough time (at least 2 weeks) and you have basic electronics knowledge.

One of the best solutions is using Arduino and Ultrasonic Sensor. There are quite enough resources on the internet about how to use an Ultrasonic sensor with Arduino. Arduino codes are also simple and have a very high learning slope.

After you understand and handle (with example codes) how to measure distance, you will need to control a motor. You can control a DC Motor with Arduino. The only thing you will need is to build a very very simple Motor Driver.

The motor driver for DC Motor is nothing but a transistor used as an ON/OFF switch. (Since microcontrollers use PWM to provide control signal).

And that's it.

NOTE:If you let your son learn how to use Arduino, he would have a basic knowledge about microcontrollers and programming, which is a good thing if your son is interested in electronics. NOTE 2: Do not supply power to motor from Arduino board. Use an external battery.

Some of the things that I mentioned here may sound unfamiliar, but a short Google search with the "keywords" that I mentioned, it will be clear.

  • \$\begingroup\$ Many thanks. I've just spent an hour researching it and it looks very interesting and do-able. Things have moved on a bit since I was young! £21 has bought me an Arduino kit, an ultrasonic proximity sensor, motor and propeller. Looking forward to it! \$\endgroup\$ – Paul Dean May 22 '15 at 12:45
  • \$\begingroup\$ @PaulDean I am glad if it is helpful. \$\endgroup\$ – Zgrkpnr May 22 '15 at 13:00

The simplest solution in my opionion would be tu use phisical probes but it requires that the probes should touch the wall.

If that is not possible probably you can use a photodioed + a diode. The diode should point on the wall so when the robot approaches the wall, more light from the diode gets reflected on the photo-diode and you know you are near te wall.

A more sophisticated system could make use of a single laser diode exploiting self mixing interferometry http://en.wikipedia.org/wiki/Self-mixing_interferometry


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.