Question: Explain the code in deep detail how it works and each line. Control Relay base on Light Sensor llThese constants won't change. They're used to
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
