0% found this document useful (0 votes)
82 views12 pages

Worksheet 2 Control of Leds With The Help of Pushbuttons and Try Different Patterns

This document summarizes a student's work on an embedded programming practical involving controlling LEDs with pushbuttons in different patterns using an Arduino board. The practical had three cases - case 1 involved turning on/off different LEDs when button 1 was pressed in a repeating pattern, case 2 did similarly for button 2 in a different pattern, and case 3 allowed a random pattern for button 2. The student's work involved connecting the hardware components on a breadboard, writing the Arduino code to implement the LED control patterns using digitalRead and digitalWrite functions on pin modes, and answering questions on what was learned from the practical.

Uploaded by

sachin kumar
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)
82 views12 pages

Worksheet 2 Control of Leds With The Help of Pushbuttons and Try Different Patterns

This document summarizes a student's work on an embedded programming practical involving controlling LEDs with pushbuttons in different patterns using an Arduino board. The practical had three cases - case 1 involved turning on/off different LEDs when button 1 was pressed in a repeating pattern, case 2 did similarly for button 2 in a different pattern, and case 3 allowed a random pattern for button 2. The student's work involved connecting the hardware components on a breadboard, writing the Arduino code to implement the LED control patterns using digitalRead and digitalWrite functions on pin modes, and answering questions on what was learned from the practical.

Uploaded by

sachin kumar
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
You are on page 1/ 12

Worksheet 2

Control of Leds with the help of pushbuttons and try different


patterns

Student Name: SACHIN KUMAR UID: 19MCA8158


Branch: MCA-LEET Section/Group C/G1
Semester: V Date of Performance: 15/08/2020
Subject Name: Advanced Embedded Programming Subject Code: CAP-820

1. Aim/Overview of the practical:


Implement LED control with the pushbuttons and following pattern in association of Arduino, Bread
Board, Resistors and multi meter: Proceed with the following cases :

Case 1: Press button 1

1. T1, T3, T5 should turn on


2. T2, T4, T6 should turn on
3. T1, T3, T5 should turn off
4. T2, T4, T6 should turn off

Case 2: Press button 2

1. T1, T3 should turn on


2. T2, T4 should turn on
3. T1, T3 should turn off
4. T2, T4 should turn off
5. T5, T6 should turn on
6. T5, T6 should turn off
Case 3: Press button 2

1. Any Random pattern instead of above two patterns


i

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

Hardware Requirements
1. Arduino UNO board
2. USB cable for connecter Arduino UNO
3. Resistor
4. Jumper wires male to female
5. 6 LED
6. 3 pushbuttons
7. 9v Hi-Walt Battery

Software requirements
1. TinkerCad

2. Circuit Diagram (TinkerCad):


4.Coding:
int buttonState = 0;
void setup()
{
pinMode(5,INPUT);
pinMode(4,INPUT);
pinMode(2,INPUT);
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
}

void loop()
{
buttonState = digitalRead(5);
if (buttonState == HIGH)
{
digitalWrite(13, HIGH);
digitalWrite(9,HIGH);
digitalWrite(7, HIGH);
digitalWrite(11, LOW);
digitalWrite(8, LOW);
digitalWrite(6,LOW);
delay(1500);
digitalWrite(11, HIGH);
digitalWrite(8, HIGH);
digitalWrite(6,HIGH);
digitalWrite(13, LOW);
digitalWrite(9,LOW);
digitalWrite(7, LOW);
delay(1500);
digitalWrite(13, LOW);
digitalWrite(9,LOW);
digitalWrite(7, LOW);
digitalWrite(11, HIGH);
digitalWrite(8, HIGH);
digitalWrite(6,HIGH);
delay(1500);
digitalWrite(11, LOW);
digitalWrite(8, LOW);
digitalWrite(6,LOW);
digitalWrite(13, HIGH);
digitalWrite(9,HIGH);
digitalWrite(7, HIGH);
delay(1500);
}
else
{
digitalWrite(13, LOW);
digitalWrite(11, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
}
delay(1000); // Wait for 1000 millisecond(s)

buttonState = digitalRead(4);
if (buttonState == HIGH)
{
digitalWrite(13, HIGH);
digitalWrite(9,HIGH);
digitalWrite(11, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
delay(1500);
digitalWrite(11, HIGH);
digitalWrite(8,HIGH);
digitalWrite(13, LOW);
digitalWrite(9,LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
delay(1500);
digitalWrite(13, LOW);
digitalWrite(9,LOW);
digitalWrite(11, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
delay(1500);
digitalWrite(11, LOW);
digitalWrite(8,LOW);
digitalWrite(13, HIGH);
digitalWrite(9,HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
delay(1500);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(13, LOW);
digitalWrite(11,LOW);
digitalWrite(9, LOW);
digitalWrite(8,LOW);
delay(1500);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
digitalWrite(13, HIGH);
digitalWrite(11,HIGH);
digitalWrite(9, HIGH);
digitalWrite(8,HIGH);
delay(1500);
}
else
{
digitalWrite(13, LOW);
digitalWrite(11, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
}
delay(1000); // Wait for 1000 millisecond(s)
buttonState=digitalRead(2);
if(buttonState==HIGH)
{
digitalWrite(13,HIGH);
digitalWrite(11,LOW);
digitalWrite(9,HIGH);
digitalWrite(8,LOW);
digitalWrite(7,HIGH);
digitalWrite(6,LOW);
delay(1000);
digitalWrite(13,LOW);
digitalWrite(11,HIGH);
digitalWrite(9,LOW);
digitalWrite( 8,HIGH);
digitalWrite(7,LOW);
digitalWrite(6,HIGH);
delay(1000);
digitalWrite(13,HIGH);
digitalWrite(11,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,HIGH);
digitalWrite(6,HIGH);
delay(1000);
digitalWrite(13,LOW);
digitalWrite(11,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
}
delay(1000);

}
5. Learning outcomes (What I have learnt):
1. Learn use of PushButton.

2. Working of Pushbutton.

3. How we control the LED’s with the help of PushButton

4. How we connect LED with PushButton

5. Learn the use of TinkerCAD.


Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):

Sr. No. Parameters Marks Obtained Maximum Marks


1. Worksheet Completion 10 marks
2. Post Lab Quiz Result 5 marks
3. Student Engagement 5 marks
(Simulation/
Demonstrate/Performance
and Pre-Lab Questions))
Total 20 marks
i

You might also like