# Rotating a motor according to calculated output [closed]

I have 13 photodiodes. Positive connection from battery is connected to the positive end of each photodiode. The position of photodiodes is as shown below:

 o  o  o
o     o
o  o  o
o     o
o  o  o


I would like to connect a motor to the output of these photodiodes.

Now when I throw infrared light on some photo diodes, they will give me 9V output as I have connected 9V battery, others will give 0 as output.

Suppose I throw light on it as below: (generated number 1)

 o  o  1
o     1
o  o  1
o     1
o  o  1


I want the motor to complete 15 iterations, stop there for 2 seconds and again complete 15 iterations in reverse direction

Suppose I throw light on it as below: (generated number 2)

 1  1  1
o     1
1  1  1
1     o
1  1  1


I want the motor to complete 30 iterations, stop there for 2 seconds and again complete 30 iterations in reverse direction

Suppose I throw light on it as below: (generated number 3)

 1  1  1
o     1
1  1  1
o     1
1  1  1


I want the motor to complete 45 iterations, stop there for 2 seconds and again complete 45 iterations in reverse direction

And similarly...

Can somebody just give me an idea of how can I accomplish the above mentioned task? and also what materials I would need?

## closed as too broad by Scott Seidman, PeterJ, pjc50, Daniel Grillo, brhansJun 22 '15 at 19:51

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1. You are going to need a microcontroller, with a large number of general purpose I/O pins. It could be done with discrete logic ICs, but it would be VERY complicated.
2. You will need a motor controller to drive the motor (H-Bridge)
3. You will need some way to detect each rotation of the motor so that your microcontroller can count the rotations. This could be mechanical (given the low number of turns) or you could use a photodiode, a light, and a reflective spot on the motor shaft.

As mentioned in pjc50's answer, the photodiodes alone won't give you a clean on/off so you'll need some additional circuitry.

Lighting just the photodiodes needed for a particular number might be kind of difficult. It might work better if you can put a cardboard cutout over the detectors and shine a larger light over the whole area. Use a 1 shaped cutout, shine the light, 15 rotations.

• Thank you for much clean information. Infact this is my first question on this site. I have just started to learn making some circuits. So, I make mistakes. As I will practice some things, I would get some idea and thus less chances of mistake. I would like to ask you 1 thing. Can you please draw my attention to get some good details on microprocessor? – Vishal Jun 19 '15 at 14:04
• I would suggest you look into the Arduino series boards. The availabe I/O pins won't quite do ( only 13 digital I/O pins if you use one pin as the motor control output PWM,) so you will need to use a shield to provide more I/O. Arduinos are made to be fairly simple for beginners. – JRE Jun 19 '15 at 14:10
• Thanks for the suggestion. I have already visited their site and I can't figure out what to purchase and what not to. Can you please help me out there? – Vishal Jun 19 '15 at 14:17
• Figure out what you need first. How many inputs will you need? How many outputs will you need? What will you need to connect the inputs and outputs to the photodiodes and motor controller? Look at the schematics and specifications of the Arduinos. See what it will accept as an input, and what it can produce for outputs. Once you've got a handle on that, you can start looking at Arduinos. Do you know the programming language "C"? The Arduino programming environment uses that language. Once you've got all that straight, you should be able to figure out what you need to order. – JRE Jun 19 '15 at 14:26
• Ya, I know C language very well. BTW I am a programmer and like to play with circuits. But don't know much about circuits. :) – Vishal Jun 19 '15 at 14:34

Firstly, photodiodes don't give you nice clean 0V/9V signals. You get better behavior from phototransistors, but you will still need some sort of thresholding system to decide where the boundary between light and dark is.

Secondly, you want to read the signals from what looks like a 7-segment display pattern, decode them, and rotate something accordingly. You will probably want a microcontroller to do the recognising. From there you have two options:

• continuous rotation servo.
• motor, possibly with a gearbox, driven by an H-bridge, with a revolution counter on the output shaft.

You don't mention what speed or precision you want on the rotation - is it OK to rotate 2.1 times or 1.9 times when you should have rotated 2 times? Do you want 1 RPM or 100 RPM?

• First of all Thank you for the great answer to my first question. I would take a look at Microcontrollers as you mentioned. I want the accuracy. So, the revolutions should be in multiples of 15. I would like speed too. But I would prefer only that motor which gives me accuracy. – Vishal Jun 19 '15 at 13:59
• Do you mean "15 full rotations" or "15 degrees"? – pjc50 Jun 19 '15 at 14:05
• I mean 15 full rotations – Vishal Jun 19 '15 at 14:05
• Easy enough. The issue is how accurately you want it to stop when it has rotated. For example you need it to line up precisely to the thousandth of an degree, that would be difficult and expensive. You probably don't. But you should come up with a number for desired accuracy. – pjc50 Jun 19 '15 at 14:19
• No, I don't want that much accuracy. I just need 15 rotations. If it's 14.9 rotations, then also its good for me. – Vishal Jun 19 '15 at 14:20