0% found this document useful (0 votes)
15 views7 pages

IoT EXP1

The document outlines a practical assignment for controlling six different color LEDs using an Arduino Uno. It includes the aim of the project, hardware and software requirements, coding examples for various LED operations, and learning outcomes related to LED functionality and programming. The assignment emphasizes understanding digital pin control, resistor selection, and timing functions in Arduino programming.

Uploaded by

priyanka gami
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)
15 views7 pages

IoT EXP1

The document outlines a practical assignment for controlling six different color LEDs using an Arduino Uno. It includes the aim of the project, hardware and software requirements, coding examples for various LED operations, and learning outcomes related to LED functionality and programming. The assignment emphasizes understanding digital pin control, resistor selection, and timing functions in Arduino programming.

Uploaded by

priyanka gami
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/ 7

Worksheet 1.1.

Student Name: Priyanka Gami UID: 23MCA20134


Branch: MCA Section/Group: 6/B
Semester: 3rd Date of Performance:24/07/24
Subject Name: Internet of Things Subject Code:23CAH-702

1. Aim/Overview of the practical:

Design a program to control a set of 6 different color LEDs connected to an Arduino Uno. Assign the LEDs the
names L1 to L6. Use appropriate resistors to protect the LEDs. Ensure that there is a delay of 300 milliseconds
between each step.

a. Turn on LEDs L1, L2, L3, L4, L5, and L6 simultaneously.


b. Turn off all LEDs (L1 to L6).
c. Make all LEDs blink simultaneously with a one-second delay.
d. LEDs L1, L3, and L5 should be on for 2 seconds, while LEDs L2, L4, and L6 should be on for 3 seconds.

2. Apparatus (For applied/experimental sciences/materials based labs):


Hardware Requirements:
a. Arduino UNO
b. Breadboard
c. LED
d. Resistor
Software requirements
a. Tinker cad

3. Circuit Diagram (Tinker Cad):


a. Turn on LEDs L1, L2, L3, L4, L5, and L6 simultaneously.
Coding:
// define LED pins
const int L1 = 2;
const int L2 = 3;
const int L3 = 4;
const int L4 = 5;
const int L5 = 6;
const int L6 = 7;

void setup() {
// Set all LED pins as output
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(L4, OUTPUT);
pinMode(L5, OUTPUT);
pinMode(L6, OUTPUT);
}

void loop() {
// Turn on all LEDs simultaneously
digitalWrite(L1, HIGH);
digitalWrite(L2, HIGH);
digitalWrite(L3, HIGH);
digitalWrite(L4, HIGH);
digitalWrite(L5, HIGH);
digitalWrite(L6, HIGH);
delay(300); // 300 ms delay
}
b. Turn off all LEDs (L1 to L6).

Coding:
void setup() {
// Set all LED pins as output
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(L4, OUTPUT);
pinMode(L5, OUTPUT);
pinMode(L6, OUTPUT);
}
Void loop(){
//Turn off all LEDs
digitalWrite(L1, LOW);
digitalWrite(L2, LOW);
digitalWrite(L3, LOW);
digitalWrite(L4, LOW);
digitalWrite(L5, LOW);
digitalWrite(L6, LOW);
delay(300); // 300 ms delay
}
c. Make all LEDs blink simultaneously with a one-second delay.

Coding:
void setup() {
// Set all LED pins as output
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(L4, OUTPUT);
pinMode(L5, OUTPUT);
pinMode(L6, OUTPUT);
}
Void loop(){
//Blink all LEDs simultaneously with a one-second delay
digitalWrite(L1, HIGH);
digitalWrite(L2, HIGH);
digitalWrite(L3, HIGH);
digitalWrite(L4, HIGH);
digitalWrite(L5, HIGH);
digitalWrite(L6, HIGH);
delay(1000); // 1 second delay
digitalWrite(L1, LOW);
digitalWrite(L2, LOW);
digitalWrite(L3, LOW);
digitalWrite(L4, LOW);
digitalWrite(L5, LOW);
digitalWrite(L6, LOW);
delay(1000); // 1 second delay
}

d. LEDs L1, L3, and L5 should be on for 2 seconds, while LEDs L2, L4, and L6 should be on for 3
seconds.

Coding:
void setup() {
// Set all LED pins as output
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(L4, OUTPUT);
pinMode(L5, OUTPUT);
pinMode(L6, OUTPUT);
}
Void loop(){
digitalWrite(L1, HIGH);
digitalWrite(L3, HIGH);
digitalWrite(L5, HIGH);
delay(2000); // 2 seconds delay

// LEDs L2, L4, and L6 on for 3 seconds


digitalWrite(L1, LOW);
digitalWrite(L3, LOW);
digitalWrite(L5, LOW);
digitalWrite(L2, HIGH);
digitalWrite(L4, HIGH);
digitalWrite(L6, HIGH);
delay(3000); // 3 seconds delay

// Turn off all LEDs before starting the loop again


digitalWrite(L2, LOW);
digitalWrite(L4, LOW);
digitalWrite(L6, LOW);
delay(300); // 300 ms delay

}
5. Learning outcomes (What I have learnt):
1. Understand how LEDs work, including the importance of correctly orienting the anode and cathode

2. Learned to calculate and select appropriate resistors for use with LEDs to ensure safe operation.

3. Understand how to control digital pins using the digitalWrite() function to turn LEDs on and off.

4. Learned to use the delay() function to create time intervals between operations.

5. Learned to use the loop() function to create a continuous sequence of operations

You might also like