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

Idea Lab Code

The document outlines several experiments involving LEDs and Arduino, including glowing a single LED, multiple LEDs in sequence, and an LED activated by motion detection using a PIR sensor. Each experiment includes code snippets for setup and loop functions to control the LEDs based on specified conditions. Additionally, there is a mention of a photo-resistor based smart lighting experiment, though details are not provided.

Uploaded by

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

Idea Lab Code

The document outlines several experiments involving LEDs and Arduino, including glowing a single LED, multiple LEDs in sequence, and an LED activated by motion detection using a PIR sensor. Each experiment includes code snippets for setup and loop functions to control the LEDs based on specified conditions. Additionally, there is a mention of a photo-resistor based smart lighting experiment, though details are not provided.

Uploaded by

sajad
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Exp: Glowing of LED

Exp 2: Glowing of multiple LEDs with the help of arduino

// Define the LED pins

const int ledRed = 13;

const int ledYellow = 12;

const int ledGreen = 11;

void setup() {

pinMode(ledRed, OUTPUT);

pinMode(ledYellow, OUTPUT);

pinMode(ledGreen, OUTPUT);

void loop() {

// 1. Red ON, others OFF

digitalWrite(ledRed, HIGH);

digitalWrite(ledYellow, LOW);

digitalWrite(ledGreen, LOW);

delay(500); // Wait 0.5 seconds

// 2. Yellow ON, others OFF

digitalWrite(ledRed, LOW);

digitalWrite(ledYellow, HIGH);

digitalWrite(ledGreen, LOW);

delay(500);

// 3. Green ON, others OFF

digitalWrite(ledRed, LOW);

digitalWrite(ledYellow, LOW);
digitalWrite(ledGreen, HIGH);

delay(500);

Exp: 3: Glowing LED on movement detection

// Define Pin Numbers

int pirSensor = 13; // PIR Signal pin connected to Digital Pin 13

int ledRed = 11; // LED connected to Digital Pin 11

int sensorValue = 0; // Variable to store sensor status

void setup() {

pinMode(pirSensor, INPUT); // PIR sensor as input

pinMode(ledRed, OUTPUT); // LED as output

[Link](9600); // Initialize Serial Monitor for debugging

void loop() {

// Read the status of the PIR sensor (1 for motion, 0 for no motion)

sensorValue = digitalRead(pirSensor);

// Output the status to the Serial Monitor

if (sensorValue == HIGH) {

digitalWrite(ledRed, HIGH); // Motion detected: Glow the LED

[Link]("Motion Detected! LED ON");

} else {
digitalWrite(ledRed, LOW); // No motion: Turn the LED OFF

[Link]("No motion. LED OFF");

delay(100); // Small delay to improve simulation stability

Exp 4: Photo-resistor based smart lighting (try)

You might also like