Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Control Relay base on Light Sensor llThese constants won\'t change. They\'re use

ID: 3843956 • Letter: C

Question

Control Relay base on Light Sensor llThese constants won't change. They're used to give names to the pins used: const int analoginPin Ao; Analog input pin that the potentiometer is attached to const int analogoutPin 3 Analog output pin that the LED is attached to const int relayPin 2; Digital Putput pin that Relay is attached to int sensorvalue o: ll value read from the pot int outputvalue 0, //value output to the PwM (analog out) void set up0 //initialize serial communications at 9600 bps: Serial begin(9600); initialize digital pin 2 as an output. pinMode(2, OUTPUT); void loop0 ll read the analog in value: sensorvalue analogRead(analoginPin); ll map it to the range of the analog out: outputvalue map(sensorvalue, 0,360, 0,255); ll change the analog out value: analogoutPin, outputvalue

Explanation / Answer

The deep details is given in following points:

i) We have taken a const integer for analog input pin and assigned it a value A0. A0 stands for analog input 0. potentiometer is attached to it.
ii) We have taken a const integer for analog output pin and assigned it with a value 3. LED is attached to analog output pin 3
iii) We also taken const integer for relayPin too.
iv) we have set the values read from the pot to 0. and analog out that is output to PWM is also set to 0.
v) In the setup function we are doing Serial.begin(9600). It means we opens a serial port and set the data rate to 9600 bps.
vi) Then in setup we initialize the digital pin 2 as OUTPUT.
vii) In loop() function we are doing following, and the this loop will keep on executing after 100 miliseconds, means we have delay of 100 miliseconds
   a) we are reading value from the pot then mapping in to the range of analog out.
   b) Then with analogWrite() we are changing the analog out value.
   c) Then we are printing the data to the serial port in ASCII text, that is human readable.
   d) Then we are checking if sensor value is less than 100 then we make relay Pin HIGH
   e) If sensor value is greater than 200 then we make relay off

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote