0% found this document useful (0 votes)
7 views3 pages

Ex No:12 Design An IOT Based System

Uploaded by

maniv2769
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)
7 views3 pages

Ex No:12 Design An IOT Based System

Uploaded by

maniv2769
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/ 3

Ex no:12

Design an IOT based system

Aim:

To design an IOT-driven system that autonomously modulates LED luminance based on real-
time ambient light intensity measurements acquired through a Light Dependent Resistor (LDR)

Algorithm:

1. Start the system.


2. Set A0 as input pin.
3. Set pin 6 as output pin.
4. Read the analog value from LDR at pin A0.
5. Map the LDR value from range 0–1023 to 0–255.
6. Write the mapped value to pin 6 to control LED brightness.
7. Repeat steps 4–6 continuously.

Program:

void setup() {

pinMode(A0,INPUT); // Set A0 as input

pinMode(6, OUTPUT);

void loop() {

int ldr = analogRead(A0); // Read the value from LDR (Light Dependent Resistor)
int bri = map(ldr, 0, 1023, 0, 255); // Map the LDR value to brightness range (0 -255)

analogWrite(6, bri); // Write the brightness value to pin 6

Output:
Result:

Thus, the experiment to design an IOT-based system that automatically adjusts LED brightness
according to ambient light intensity sensed by an LDR (Light Dependent Resistor) has been
successfully written, executed, and the output has been verified.

You might also like