Question

In: Computer Science

The purpose of this project is to use two light sensors (photoresistors) to measure light intensity...

The purpose of this project is to use two light sensors (photoresistors) to measure light intensity in two opposite positions (0 & 180°) and indicate the position with a servomotor. The materials that will be used are: two light sensors, one Arduino micro-controller, two LEDs, and one servo motor. Each LED will indicate when a photoresistor is illuminated (positioned on opposite sides of the servomotor), while the servomotor moves to the illuminated side. In addition, when the intensity of the two photoresistors is almost the same, the servo motor must be placed in a central position (90°), and both LEDs must be turned off. Please use serial print to track the code. Thanks

Solutions

Expert Solution

Connections are made as per the requirements given. The circuit in tinkerCad is shown below.

Code for the above given circuit is attached below.


#include <Servo.h>
int ldr_180=0;       //photoresistor at 180 pin number
int ldr_0  =1;       //photoresistor at 0   pin number
int led_180=6;       // LED indicating 180 servo angle pin
int led_0  =7;       // LED indicating   0 servo angle pin

int value_180=0;   // ldr at 180 value
int value_0  =0;   // ldr at   0 value

Servo servo_9;   // servo motor varible
 
void setup()
{
  servo_9.attach(9);        //declaring the pin for servo motor
  pinMode(led_180,OUTPUT);  //declaring the led pin as OUTPUT
  pinMode(led_0,OUTPUT);    //declaring the led pin as OUTPUT
  pinMode(ldr_180,INPUT);   //declaring the ldr pin as INPUT
  pinMode(ldr_0,INPUT);     // declaring the ldr pin as INPUT
  Serial.begin(9600);

}

void loop()
{

  value_180 = analogRead(ldr_180);  // reading photoresistor values
  value_0 = analogRead(ldr_0);   // reading photoresistor values
  Serial.print("LDR at 180 degrees intensity ");
  Serial.println(value_180);
  
  Serial.print("LDR at 0 degrees intensity ");
  Serial.println(value_0);
  
  if (value_180>value_0){           // if left LDR as more light
    digitalWrite(led_180,HIGH);    // LED at 180 is ON
    digitalWrite(led_0,LOW);       // LED at 0 is OFF
    servo_9.write(180);            // servo motor is turned to 180
    Serial.println("Turned to 180");
  }
  
  if (value_0>value_180){         // if right LDR as more light
    digitalWrite(led_0,HIGH);     // LED at 0 is ON
    digitalWrite(led_180,LOW);    // LED at 180 is OFF
    servo_9.write(0);             // servo motor turned to 0
    Serial.println("Turned to 0");
  }
  
  if (value_180==value_0){        // if both are equal
    digitalWrite(led_180,LOW);    // LED is OFF
    digitalWrite(led_0,LOW);      // LED is OFF
    servo_9.write(90);            // Servo at 90
    tone(10,255,400);             // buzzer is ON
    delay(1000);
    noTone(10);
    Serial.println("Turned to 90");
  }
  
  delay(800);   // delay helps to observe the serial monitor clearly
  // you can remove it.
  
}

Make sure you connect the circuit as shown in the circuit.

Some of the results are shown below.

Hope you got the answer. If you still have any doubts regarding this, please try to comment, I will solve them for you.


Related Solutions

The Affect Intensity Measure (AIM) was developed as a questionnaire measure of affect intensity or emotional...
The Affect Intensity Measure (AIM) was developed as a questionnaire measure of affect intensity or emotional variability and volatility. . Identify three articles published in the last five years that use the AIM to assess affect intensity, and investigate the relationships between affect intensity and some other individual difference variable. How relevant to our lives are their results can you pleas help me with this . thank you can you pleas add the refrences
The Affect Intensity Measure (AIM) was developed as a questionnaire measure of affect intensity or emotional...
The Affect Intensity Measure (AIM) was developed as a questionnaire measure of affect intensity or emotional variability and volatility. . Identify three articles published in the last five years that use the AIM to assess affect intensity, and investigate the relationships between affect intensity and some other individual difference variable. How relevant to our lives are their results can you pleas help me with this . thank you
Explain the reasons for the number of intensity maxima and intensity minima seen in light polarization...
Explain the reasons for the number of intensity maxima and intensity minima seen in light polarization graphs. Show figures with the orientation of the electric field and the axis of transmission of the polarizer.
A beam of light is a mixture of unpolarized light with intensity Ia and linearly polarized...
A beam of light is a mixture of unpolarized light with intensity Ia and linearly polarized light with intensity Ib. The polarization direction for the polarized light is vertical. When this mixed beam of light is passed through a polarizer that is vertical, the transmitted intensity is 16.8 W/m2; when the polarizer is at an angle of 55.0° with the vertical, the transmitted intensity is 8.68 W/m2. (a) Is Ia greater than, less than, or equal to Ib? Explain. (b)...
questions 1) : How to control the polarization of light and intensity and phase of light...
questions 1) : How to control the polarization of light and intensity and phase of light ???? questions 2) : How to control the polarization, intensity, phase of liquid crystal ???
Consider how the intensity of light changes as it passes between two Polaroid disks at different...
Consider how the intensity of light changes as it passes between two Polaroid disks at different angles to each other. (For this scenario, suppose that the polaroid closest to the light source remains fixed with the zero degree marking pointing straight up. Therefore, the second Polaroid disk is the one being rotated, and the angles for the graph should be the angle between the zero degree marking of the first disk and the position of the second disk. ) a....
In an experiment to measure the wavelength of light using two slits, it is found that...
In an experiment to measure the wavelength of light using two slits, it is found that the interference fringes are too close together to easily count them. To spread out the fringe pattern, one could… A. Increase the slit separation B. Decrease the slit separation C. Increase the distance from the slits to the viewing screen D. Decrease the distance from the slits to the viewing screen E. Both increasing the distance from the slits to the viewing screen and...
Effect of intensity on photoelectrons What effect does changing the light intensity have on the maximum...
Effect of intensity on photoelectrons What effect does changing the light intensity have on the maximum energy of the photoelectrons and what evidence supports your answer? What effect does changing the light intensity have on the charging time and why? Effect of frequency on photoelectrons What effect does changing the frequency of the light have on the maximum energy of the photoelectrons and what evidence supports your answer? Are any of the frequencies used below the threshold (work function) of...
You are investigating two sensors to use in an experiment. Sensor A has area 600 ±...
You are investigating two sensors to use in an experiment. Sensor A has area 600 ± 0.3 mm2 and the gap thickness is 0.3 ± 0.01 mm. Sensor B has area 400 ± 0.25 mm2 and the gap thickness is 0.2 ± 0.02 mm. Estimate the relative (hint: this is a %) and absolute uncertainties (hint: this has units of capacitance) in capacitance for both sensors. Your experiment requires that the capacitance is measured accurately within 5%. Which would you...
Vertically polarized light that has an intensity of 450 W/m2 isincident on two polarizing filters....
Vertically polarized light that has an intensity of 450 W/m2 is incident on two polarizing filters. The first filter is oriented 30° from the vertical while the second filter is oriented 75° from the vertical. Predict the intensity and polarization of the light that emerges from the second filter. (Assume both angles are measured in the same direction with respect to the vertical.) _________W/m2 Please help! Thanks!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT