0% found this document useful (0 votes)
33 views1 page

Exercise 12 - Auto Brightness

The document outlines the design of an IoT-based system that adjusts LED brightness according to ambient light intensity detected by an LDR. It includes an algorithm and a program written in code to implement the system. The experiment was successfully executed and the output verified.

Uploaded by

gcetly.2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views1 page

Exercise 12 - Auto Brightness

The document outlines the design of an IoT-based system that adjusts LED brightness according to ambient light intensity detected by an LDR. It includes an algorithm and a program written in code to implement the system. The experiment was successfully executed and the output verified.

Uploaded by

gcetly.2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Ex. No.

12 Design IoT-based system


Date: 03-04-2024

Aim:
To design an IoT-based system that adjusts the brightness of an LED based
on the ambient light intensity sensed by an LDR (Light Dependent Resistor).

Algorithm:
Step 1: Start
Step 2: Set up pin A0 as INPUT to read the analog value from the LDR.
Step 3: Set up pin 6 as OUTPUT to control the LED brightness.
Step 4: Read the analog value from the LDR.
Step 5: Map the LDR reading to the brightness range.
Step 6: Adjust the brightness of the LED based on the mapped value.
Step 7: Repeat Step 3 to 5
Step 8: Stop

Program:
// Setup function to initialize pins and variables
void setup() {
// Set pin A0 as INPUT to read analog value from LDR
pinMode(A0, INPUT);
// Set pin 6 as OUTPUT to control LED brightness
pinMode(6, OUTPUT);
}

// Loop function to continuously read LDR value and adjust LED brightness
void loop() {
// Read analog value from LDR
int ldr = analogRead(A0);
// Map LDR reading to brightness range (0-255)
int bri = map(ldr, 0, 1023, 0, 255);
// Adjust LED brightness based on mapped value
analogWrite(6, bri);
}

Result:
Thus the experiment to design an IoT-based system that adjusts the brightness
of an LED based on the ambient light intensity sensed by an LDR (Light Dependent
Resistor) is written, executed and output is verified.

You might also like