Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

COMPUTER HARDWARE ESSENTIALS

- cb.sc.u4cse23233
Question 1)

int Potentiometer=15;

int LED=32;

int sensor_value=0;

void setup()

pinMode(LED,OUTPUT);

pinMode(Potentiometer,INPUT);

Serial.begin(115200);

void loop()

Sensor_value=analogRead(Pot);

Serial.print(sensor);

analogWrite(LED,sensor);

delay(100);

OUTPUT:
Question 2)

UTILIZATION OF LDR:

The LDR can be used to find the intensity of the ambient light conditions and based on the reading that
the sensor provides I will be able program when the brightness of the LED should be increased and when
the brightness of the led should be decreased.

UTILIZATION OF LED:

The LED is adjusted based on the reading that is provided by the LDR sensor, that is the LED is used as a
light source for the OUTPUT, that is to increase the brightness in low-light conditions and decrease it
when there's sufficient ambient light.

ADVANTAGES IN TERMS OF ENERGY CONSUMPTIONS:

By adjusting the brightness of the LED lights in response to ambient light conditions, the system can
optimize energy consumption, which helps in energy conservation. The system auto adjusts the LED so
the user doesn’t have to manually dim or increase the brightness of the LED.

The system can adapt to seasonal changes, weather conditions, and variations in natural light, ensuring
consistent and appropriate outdoor lighting.

Question 3)
int led_red=9;

int led_green=5;

int led_yellow=3;

int led_blue=6;

int ldr_pin=A0;

int potentiometer=A5;

int Threshold_max=3000;

int Threshold_min=1000;

int slide_switch_pin=0;

void setup()

Serial.begin(9600);

pinMode(led_red,OUTPUT);

pinMode(led_green,OUTPUT);

pinMode(led_yellow,OUTPUT);

pinMode(led_blue,OUTPUT);

pinMode(ldr_pin,INPUT);

pinMode(potentiometer,INPUT);

pinMode(slide_switch_pin,INPUT);

void loop()

int switch_input=digitalRead(slide_switch_pin);

int potentiometer_reading=analogRead(potentiometer);

int ldr_reading=analogRead(ldr_pin);
if (switch_input==1){

analogWrite(led_red,potentiometer_reading);

if (switch_input==0){

digitalWrite(led_red,LOW);

digitalWrite(led_blue,LOW);

digitalWrite(led_yellow,LOW);

digitalWrite(led_green,LOW);

OUTPUT:

RUNNING:

You might also like