Motor Speed Control with LED,s and LDR,s question

I have been tasked with a project of controlling motor speed using a very strange method, and need some general help. Instead of a Pot being used the task at hand is to use two LED,s and two LDR,s as well as a perforated disk to control the speed. When the disk is turned clockwise the motor should speed up and when the disk is turned anti clockwise it is to slow down. Disk design is entirely up to me by the way

I have a general understanding of what needs to be done. The LED,s should be put on one side of the disk and the LDR on the other so as when turning the led only shines through the holes in the disk. however i have a few questions im hoping someone can answer;

how would i go about detecting the clockwise and anticlockwise turns of the disk

how would i code the motor speed to scale to the rotations of the disk

general tips also appreciated

note: no external components can be used besides the basic arduino board, components mentioned and general transistors resistors.

LDRs respond slowly. You would be better using photo-transistors as detectors. You can buy slotted optical switches that have both the LED and photo transistor in a neat package.

The usual way to identify the direction of rotation is to arrange things so that one detector triggers before the other. Then by checking which was triggered first you can identify the direction.


how would i go about detecting the clockwise and anticlockwise turns of the disk

This shows how quadrature encoders work.

As for scaling, that is something to work out experimentally. the analogWrite function that you would use for speed control has a range of 0 to 255. The range of frequencies that the encoder puts out would be scaled to fit 0 (or the minimum duty cycle that starts the motor) to 255.

I agree with Robin2, LDRs are too slow for this application unless the disc were rotated pretty slowly.

The project is an end of semester college thing for electronic engineering. Practically it would be better to use something other than the LDR's but those were the components provided and external components were not allowed.
Appreciate the replies and the tips on getting the clockwise and anti-clockwise working. As for the scaling i will have to figure that out after the disk is built.

Also the disk would be rotated slow enough. it would be hand rotated the overall project is to design and code it so it works almost like a potentiometer

I suggest you build some test disks with different sizes and number of gaps and experiment with a single LED/LDR combination to see what works best.

I am using LDRs to detect model trains using ambient light and they give a good digital indication when coupled with a 220k resistor to make a voltage divider. If your LED is bright you could probably reduce the value of the fixed resistor.