Introduction: User Photoresistor With Arduino Control DC Motor Project

The Photoresistor With Arduino Control DC Motor project is a simple and interactive project that combines the use of a photoresistor (light-dependent resistor) and an Arduino board to control the speed of a DC motor based on the intensity of light. The photoresistor acts as a light sensor, and the Arduino board processes the sensor data to control the motor's speed through a motor driver module.

By implementing this project, you can explore the concepts of analog input reading, analog-to-digital conversion, and motor control using Arduino. The project allows you to create an automated system that adjusts the motor speed based on changes in the surrounding light, making it suitable for applications such as light-sensitive devices, solar trackers, or ambient light control systems.

The project involves setting up the circuit by connecting the Arduino board, photoresistor, motor driver module, and DC motor. The Arduino code reads the analog values from the photoresistor, maps them to motor speed values, and uses the motor driver module to control the motor's speed. As the intensity of light changes, the motor speed adjusts accordingly, demonstrating a real-time response to the surrounding light conditions.

This project documentation will guide you through the necessary steps to assemble the circuit, write the Arduino code, and test the functionality of the photoresistor-controlled DC motor. Feel free to modify and expand the project based on your creativity and requirements. So, let's get started with the step-by-step instructions!

Supplies

Attachments

Step 1: Gather the Required Materials


  • Arduino board (e.g., Arduino Uno)
  • Breadboard
  • Photoresistor (also known as LDR - Light Dependent Resistor)
  • DC motor
  • Motor driver module (such as L293D or L298N)
  • Jumper wires
  • Power supply for the motor (battery pack or external power source)
  • Resistors (optional, depending on the photoresistor used)


Step 2: Set Up the Circuit

  • Connect the Arduino board to the breadboard.
  • Connect the power and ground pins of the motor driver module to the appropriate power and ground rails on the breadboard.
  • If necessary, connect a resistor in series with the photoresistor to create a voltage divider circuit to get more accurate readings (the value of the resistor will depend on the specific photoresistor used).


Step 3: Write the Arduino Code

// C++ code

//

int sensorValue = 0;

int voltage;

int timer = millis();

void setup()

{

 pinMode(A0, INPUT);

 Serial.begin(9600);

 pinMode(9, OUTPUT);

 pinMode(12, OUTPUT);

 pinMode(8, OUTPUT);

}


void loop()

{

 // read the value from the sensor

 sensorValue = analogRead(A0);

 // print the sensor reading so you know its range

 Serial.println(sensorValue);

 // map the sensor reading to a range for the LED

 analogWrite(9, map(sensorValue, 0, 1023, 0, 255));

 if(sensorValue > 200){

  

  digitalWrite(8, HIGH);

     digitalWrite(12, LOW);

 

   

 }

   else{


    digitalWrite(8, LOW);

     digitalWrite(12, LOW);

 

   }

  

 delay(100); // Wait for 100 millisecond(s)

}

Step 4: Simulation in Tinkercad

Photoresistor with Arduino control DC motor