Using Light Sensor to Activate DC Motor

I am attempting to create a circuit that activates a DC motor when the photoresistor detects light, and I used tinkercad to simulate it. It worked in tinkercad, but when I tried to create it in person, it didn't seem to work. When I check the photoresistor values, it constantly reads 0 even when the light is on. The transistor is used as an amplifier. I have attached a photo of the tinkercad circuit and the video of my real life circuit.

int analogValue;
int voltage;
int timer = millis();
void setup()
{
  pinMode(A0, INPUT);
  pinMode(7, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  analogValue = analogRead(A0);
  analogWrite(7, voltage);
  if(analogValue > 200){
    if((millis() - timer) > 5000){
    digitalWrite(7, HIGH);
    }
  }
      else{
        timer = millis();
       digitalWrite(7, LOW);
      }
  Serial.print("Photoresistor Value: ");
  Serial.println(analogValue);
  delay(1000);
}

Below is a video on the circuit I created:

If anyone could help me figure out why it does not work, I would greatly appreciate it! Thank you.

What is the characteristics of the photoresistor and the value of the resistor?

It's weird, but I have figured it out. Using a voltmeter, I found that the LDR was not receiving any voltage, so I moved my jumper cables near where it was placed, and it started detecting values. As for the motor, I had to connect the ground to emitter instead of the collector.

Okey. Poor contact to the LDR....
Don't run motor current from breadboard.
It is is not designed for that current.

Railroader:
Okey. Poor contact to the LDR....
Don't run motor current from breadboard.
It is is not designed for that current.

I bought a relay for the motor, but I still need to get male to female jumper wires. Would that be fine instead of connecting it to the breadboard?

Don't rely on jumper cables. There are no such cables for everything. Get yourself soldering equipment.

The sight is slow to update. Replies comes very late.
Check transistor max current versus motor max current.
Note that Arduinos don't have capacity for common relays. They often need a transistor to power the relay coil. Lots of work for no good.

tabitha_twitchett:
When you say "a relay" do you literally mean a bare relay, or do you mean a relay on a board with other electronics to make it work properly, normally known as a relay module.

In either case, you need to provide details about it for informed advice.

Yes, my bad. It is a relay MODULE.

Fine. Check what current it needs. Most likely an Arduino can turn the module on and off.

Hi,
What switching transistor are you using?
What motor are you using?
Can you post a picture of your project so we can see your component layout?

Thanks.. Tom... :slight_smile: