# Making an obstruction avoiding device without microcontroller

I want to make a toy device which spins to the left whenever there is an obstruction in front of it, without any microcontroller. Can anybody please check whether my approach in building the device is correct or not [let's assume we are driving our device in a bright room with uniform lighting]? Any tips or suggestions for improvement (if it is correct) will also be appreciated.

My approach is to use two DC motors as the rear wheels of the device. Attach an LDR to the front of the device and connect it to the left motor. Now both the motors are connected to a power supply. When the power supply is switched on and no obstruction is in front of the toy, both the motors will be moving at approximately same speed since the LDR will be in exposure to light and its resistance will be negligible, because of which the toy will run straight. Now when there is some obstruction in front of the device, the amount of light falling on the LDR will decrease, which will imply a rise in resistance of the LDR. Thus the velocity of the left motor will decrease, while the velocity of the right motor will be moreorless constant. So the device will spin to the left.

The circuit diagram corresponding to my argument is provided in the link below. I will post the mechanical simulation of the device shortly (within 2 hours from now).

• In principle it will do what you expect but you'll need to use the LDR into an amplifier so that the motor is controlled because its resistance is unlikely to be able to power much even when totally illuminated – Andy aka Jun 1 '13 at 16:02
• I am the one who asked this question [sorry for asking through the fake account, I was in a hurry actually]. Since I can't comment I am posting it as an answer. @Andy aka, The LDR is not used to power the motor, instead it is used to reduce the velocity of the motor. Since the velocity of the other motor remains constant as it is not connected to the LDR, the vehicle should turn about the direction of the motor connected to the LDR. – abcd Jun 1 '13 at 17:15
• What is the resistance of the LDR when it is lit? Is it zero ohms? Even if it is 10 ohms, you'll need the equivalent of that resistance in the uncontrolled motor line to balance things to keep it in a straight line. How much current do the motors take? 500mA? If 500mA, at half motor speed from 6V battery, the power disippated in the LDR will be likely enough to torch it. – Andy aka Jun 1 '13 at 17:24
• The motors take 500 mA current each. The LDR has minimum resistance nearly equal to 1 Ohms. The 1 Ohms resistor can be placed in the motor line to balance the speed of the motors. But do you think it will work? I am currently designing the mechanical simulation of the device and will upload it soon. – abcd Jun 1 '13 at 17:31
• I think you may be reinventing a BEAM popper or photovore – RedGrittyBrick Jun 1 '13 at 23:42

No, this won't really work. Your idea sortof makes sense in theory, but you are missing some down to earth practicality issues.

First, consider the kind of currents the motors in even a small toy would require. Then consider how low a resistance the LDR would need to have so that the voltage drop to the right motor is negligible. It would probably need to be less than 1 Ω, which is well below the practical range for LDRs.

Even if this did work, it would not be very efficient and the LDR would dissipate significant power when it is in the half-on state. Wasting power is not a good thing when batteries are in use. LDRs are much more suitalble as sensors instead of resistive pass elements for significant power.

You have given no valid reason for avoiding a microcontroller, probably because there is none. If your reasons are religious, then your whole question is off topic here. This is a engineering site where we discuss solutions to real problems.

A microcontroller reading light intensity from a LDR used as sensor, then driving each motor with PWM to modulate its drive level is the obvious and efficient way of doing this. With that setup, it would be simple to have two LDRs, one on each side, and have the device always drive towards the strongest light.

I see in some comments you made (now deleted) that you think avoiding a microcontroller reduces cost. This is not true. Using a microcontroller will be the lowest cost solution that actually works. You mentioned the price of a arduino, but only a tiny fraction of that is the cost of the microcontroller, so is not relevant. The motors, mechanical drive train assembly, and battery will all cost more than a reasonable microcontroller for this job. Many micros are available for under $1. I didn't look all that carefully, but from a first glance a PIC 12F1501 looks like it can do this job. It is listed as$.49 in 5k quantity.

Since there is some objection to providing only the 5k quantity price here for some reason, I looked up a example version of this part on microchipdirect, just like anyone else can do that wants detailed pricing. You could also look on distributor web sites, like Mouser. There are lots of places to buy PICs in various quantities.

Specifically, as a example, the PIC 12F1501-I/SN, which is the commerical temperature grade in SOIC package is available on microchipdirect in single pieces with the price for up to 25 units being $.67 each. Of course there is shipping added to that, so buying a single unit is silly. Generally you'd buy a bunch of parts for a whole project at once, preferably with a few spares from Mouser or wherever. All I'm trying to point out is that these things are cheap and to give a rough idea of price. The details are the job of anyone actually doing the design to chase down, as always. • If OP is a developer creating something for mass production, a$2500 investment in bulk chips might be appropriate. If OP is a hobbyist building a one off, 4,999 left over chips might not be the way to go. My guess is OP is a hobbyist, but I don't think we have enough information to know for sure. – mikeY Jun 2 '13 at 19:00
• @mike: Your points are invalid. 1: If the OP is a hobbyist, then the price of a single micro is pretty much irrelevant and his worry about the cost pointless. It doesn't matter if it's $.50 or$5 if he's only buying one. Still cheap compared to the motors, drive train, and batteries. 2: You are confusing bulk price with minimum order quantity. Of course you can buy single PIC 12F1501 for maybe 1$to 2$. I showed the 5k price because that's more relevant when you're worrying about a few cents per micro. I never said you could only buy them 5k at a time. Read more carefully. – Olin Lathrop Jun 2 '13 at 19:08
• My points are perfectly valid. I said we didn't have enough information to know. We don't. I think quoting things at the 5k price and "worrying about a few cents per micro" is making assumptions about the OP. I think the OP's schematic suggests he is a hobbyist. But again, we don't know. I can tell you with certainty that as a hobbyist, someone quoting a 5K price to me, even when meant as an illustration, is not helpful. – mikeY Jun 3 '13 at 0:51
• @mikey: As you say, we don't know if he is a hobbyist or not. In any case, I gave one example price point. Getting bent out of shape because that single example may not apply to the OP is a gross overreaction. Anyone can spend a minute on the internet and determine the price for whatever quantity they actually want. In the mean time, I gave a particular model number to look into further. It seems I could have left the one example price off and you would have thought the answer better. Dinging the whole answer because one example might not be relevant rather a stretch. – Olin Lathrop Jun 3 '13 at 12:25
• I didn't downvote or ding your answer- in fact I have upvoted it. You provided an actual answer and addressed OP's questions. I didn't do that. You get credit for that in my book. I'm not bent out of shape either. I made my comments because I didn't/don't like some of what you said. I think your orientation and assumptions are wrong. But it is perfectly fine if we disagree. – mikeY Jun 3 '13 at 15:09

Instead of a continuous current variation against the light falling on the sensor, if you can use an on/off approach, this would be workable, with minimal wasted power. In other words, one of the motors would simply turn off if light falling on the LDR is obstructed. The solution would cost much less than the Arduino, 10 such devices could be made for under $10. simulate this circuit – Schematic created using CircuitLab • The preset R1 shown in the schematic allows the light level tripping threshold to be set. • R2 simply prevents the base of Q1 from being shorted to Vcc if R1 is set to 0 Ohms. • Q1 is used for gain, to provide a sharper turning on or off of the MOSFET. A useful change would be to connect an LED as a light source, right next to the LED and facing the same direction. Any obstruction directly in front of the device would reflect the LED's light into the LDR, causing the light level to rise instead of fall, hence causing the LDR's resistance to fall instead of rise. Simply swap positions of the LDR and R1+R2, to invert the motor's operating mode accordingly. Common infrared reflective sensors such as the TCRT5000 are available for less than$1 for 10 pieces, possibly cheaper than the LDR mentioned in the question. This can be used as such an active obstruction sensor, eliminating the need for the LDR and ensuring that dependency on ambient room lighting is removed. The IR LED part of the TCTR5000 is wired up through a suitable current limiting resistor, and the sensor part is used to sense the reflected IR from obstructions. If the reflected intensity goes beyond a threshold you set, the motor stops.

This page, from which the above image is taken, also provides a schematic of how the IR obstruction sensor may be wired up:

This schematic shows the (photo)transistor in a common collector configuration, but it can just as well be used as common emitter. Hence. the phototransistor output can be used in place of the 2n2222 in the first schematic above, to directly drive the MOSFET.