Photo Resistor to DC Motor

Pretty much I have an architectural design project where I want a photo resistor to control how fast a DC motor spins, I.E. when it is brighter I want it to spin faster. I have tried looking all over the forum and the internet but to no avail. My teacher said that no matter what we want to do someone has done it so just copy and paste it into the arduino program but it seems like noone has done this but I know someone must have. we do not need to know how to code (not the point in the class) so in helping you will not be damping my education. Okay so what I need is the code and where to plug in the wires. I am sorry if this is really blunt.

Note that your project can be decomposed into two projects, reading a photo sensor and running motor at variable speed, each of which has been done a lot, so you may need to put these two things together.

Here are some more details that anyone would need to be able to provide you with code or wiring help.

First, what size motor are we dealing with? Is this a small hobby motor or something larger and more powerful?

What voltage does the motor need to run?

Does it need to run in both directions or only one?

Do you have switching electronics already (MOSFET, motor driver IC, etc.)?

Will light make the motor spin more or less fast?

Lastly, while you wouldn't have to write the code from scratch, understanding and copying examples would be a very good idea.

Likely what you will do to read the photo resistor is place it in series with another resistor with five volts over the pair to make a voltage divider. Then you will use the analogRead(pin) function to find the light value. You will then do a little bit of math to correlate this value to a given motor speed and then use the analogWrite(pin, value) function to set the speed of the motor. The final code should be short and sweet, but it is dependent on some of the things I listed above.

Here are some examples to get your creative juices flowing.

http://learn.adafruit.com/photocells/overview

http://bildr.org/2012/03/rfp30n06le-arduino/ This will allow unidirectional motor operation only. Search for H-bridge controllers for bidirectional opperation.

My teacher said that no matter what we want to do someone has done it

Your teacher is an idiot.

so just copy and paste it into the arduino program

So your teacher says that copying the work of some one else is OK for you to do. He really is an idiot if that is what he said or we really are idiots if you expect us to believe that.

The point of a teacher is to educate, your education experience is very poor if this is true, demand better. I know, I was a teacher at a University.

What subject did you teach?

[quote author=Drew Davis link=topic=168794.msg1258785#msg1258785 date=1369871566] What subject did you teach? [/quote] Electronics, physics, computer instrumentation and Astronomy.

what is the code of this project (to control the dc motor by using LDR sensor ??