Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

School of Electronics Engineering (SENSE)

B. Tech–Electronics & Computer Engineering

ECE4003–EMBEDDED SYSTEM DESIGN


LAB RECORD
(L43+L44)

Submitted By
19BLC1137 – SAKSHAM MISHRA

Submitted To
Dr. Manoj Kumar Rajagopal
DATE: 04/08/2021

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 1


LAB – 01 Working with LED & Switch

LABTASK-1:
AIM:
Write a program to blink three LEDs (Green, Yellow, Red) interfaced with three digital pins of
Arduino Uno as per following sequence.
 First turn ON Green LED for 15 Sec. while other LEDs in OFF state
 Then turn ON Yellow LED for 3 Sec. while other LEDs in OFF state
 Then turn ON Red LED for 10 Sec. while other LEDs in OFF state
 Repeat this sequence continuously
Simulate and verify this logic on Arduino Uno using Tinkercad circuits simulator.

API REQUIRED:
 pinMode(pin, mode) - Configures the specified pin to either input or output.
- pin: the Arduino pin number to set the mode of.
- mode: INPUT, OUTPUT, or INPUT_PULLUP.

 digitalWrite(pin, value) - Write a HIGH or a LOW value to a digital pin.


- pin: the Arduino pin number.
- value: HIGH or LOW.

 delay(ms) - Pauses the program for the amount of time (in milliseconds)
- ms: the number of milliseconds to pause.

PROGRAM:
int GREEN=0;
int YELLOW=1;
int RED=2;

void setup()
{
pinMode(GREEN, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(RED, OUTPUT);
}

void loop()
{

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 2


digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, LOW);
delay(15000); // Wait for 15000 millisecond(s)

digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
digitalWrite(RED, LOW);
delay(3000); // Wait for 3000 millisecond(s)

digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, HIGH);
delay(10000); // Wait for 10000 millisecond(s)

OUTPUT:

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 3


TINKERCAD LINK: https://www.tinkercad.com/things/5FKHp3BzC2T

INFERENCE:
I used pinMode(pin,mode) to specify output to the three leds and we use digitalWrite(pin,value) to
assign high value to the three leds as per the sequence of time described in the statement.

RESULT:
I successfully simulated and veified the logic in the problem statement on Arduino Uno using
Tinkercad circuits simulator.

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 4


LABTASK-2:
AIM:
Write a program to control four LEDs in a Hexadecimal pattern from 0 (0000) to F (1111) in a sequential
order with 0.5 Sec delay between each. Once it reach F, the sequence must continue again from 0.
Simulate and verify this logic on Arduino Uno using Tinkercad circuits simulator.

API REQUIRED:
 pinMode(pin, mode) - Configures the specified pin to either input or output.
- pin: the Arduino pin number to set the mode of.
- mode: INPUT, OUTPUT, or INPUT_PULLUP.

 digitalWrite(pin, value) - Write a HIGH or a LOW value to a digital pin.


- pin: the Arduino pin number.
- value: HIGH or LOW.

 delay(ms) - Pauses the program for the amount of time (in milliseconds)
- ms: the number of milliseconds to pause.

PROGRAM:
bool n[4]={0,0,0,0};
int RED[4] = {0,1,2,3};
int i=1;

void setup()
{
for(int i=1;i<4;i++)
{
pinMode(RED[i],OUTPUT);
}
}
void loop()
{
for(int i=1;i<4;i++)

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 5


{
digitalWrite(RED[i],n[i]);

}
delay(500);

n[0]=!n[0];
if(i%2==0) n[1]=!n[1];
if(i%4==0) n[2]=!n[2];
if(i%8==0) n[3]=!n[3];
i++;
if(i==17) i=1;
}

OUTPUT:

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 6


TINKERCAD LINK: https://www.tinkercad.com/things/6U702PSzcSn

INFERENCE:
I learned the use of required API’s and learned the logic for the code to display hexadecimal
pattern using LEDs.

RESULT:
I successfully simulated and veified the logic in the problem statement on Arduino Uno using
Tinkercad circuits simulator.

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 7


LABTASK-3:
AIM:
Write a program to control two LEDs (Green, Red) state using a switch as per following logic.
 When switch is not pressed (LOW) turn ON Red LED continuously and Green LED in OFF state
 Whenever switch is pressed (HIGH) turn OFF Red LED and turn ON Green LED for 10 Sec.
 After 10 Sec. delay turn OFF Green LED and proceed to turn ON Red LED continuously
Simulate and verify this logic on Arduino Uno using Tinkercad circuits simulator.

API REQUIRED:
pinMode(pin, mode) - Configures the specified pin to either input or output.
- pin: the Arduino pin number to set the mode of.
- mode: INPUT, OUTPUT, or INPUT_PULLUP.

digitalWrite(pin, value) - Write a HIGH or a LOW value to a digital pin.


- pin: the Arduino pin number.
- value: HIGH or LOW.

delay(ms) - Pauses the program for the amount of time (in milliseconds)
- ms: the number of milliseconds to pause.

digitalRead(pin) - Reads the value from a specified digital pin, either HIGH or LOW.
- pin: the Arduino pin number.

PROGRAM:
int GREEN = 0;
int RED = 1;
int SWITCH = 2;
int SWITCHSTATE;

void setup()
{
pinMode(GREEN, OUTPUT);
pinMode(RED, OUTPUT);
pinMode(SWITCH, INPUT);

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 8


}

void loop()
{
SWITCHSTATE = digitalRead(SWITCH);
if (SWITCHSTATE == HIGH)
{
digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
delay(10000);
}
else
{
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
}
}

OUTPUT:

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 9


TINKERCAD LINK: https://www.tinkercad.com/things/6wCxACNPs6a

INFERENCE:
I learned the use digitalRead API and how to use a switch.

RESULT:
I successfully simulated and veified the logic in the problem statement on Arduino Uno using
Tinkercad circuits simulator.

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 10


LABTASK-4:
AIM:
Write a program to blink four LEDs one at a time from left to right with 0.5 sec delay. Whenever a switch
is pressed, the LED blinking happens from right to left with delay of 0.25s between each LED. When the
Switch is released again the sequence change to left to right with 0.5s delay.

API REQUIRED:
pinMode(pin, mode) - Configures the specified pin to either input or output.
- pin: the Arduino pin number to set the mode of.
- mode: INPUT, OUTPUT, or INPUT_PULLUP.

digitalWrite(pin, value) - Write a HIGH or a LOW value to a digital pin.


- pin: the Arduino pin number.
- value: HIGH or LOW.

delay(ms) - Pauses the program for the amount of time (in milliseconds)
- ms: the number of milliseconds to pause.

digitalRead(pin) - Reads the value from a specified digital pin, either HIGH or LOW.
- pin: the Arduino pin number.

PROGRAM:
int RED[]={0,1,2,3};
int SWITCH=4;
int SWITCHSTATE;

void setup()
{
for(int i=0;i<4;i++){
pinMode(RED[i], OUTPUT);
}
pinMode(SWITCH,INPUT);
}

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 11


void loop()
{
SWITCHSTATE=digitalRead(SWITCH);
if(SWITCHSTATE==HIGH){
for(int i=3;i>=0;i--){
digitalWrite(RED[i], HIGH);
delay(500);
digitalWrite(RED[i],LOW);
}
}
else
{
for(int i=0;i<4;i++){
digitalWrite(RED[i], HIGH);
delay(500);
digitalWrite(RED[i],LOW);
}
}
}
OUTPUT:

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 12


TINKERCAD LINK: https://www.tinkercad.com/things/6siPVKaDF3w

INFERENCE:
I learned the use of switch and learned what logic to use to write code for the problem
statement.
RESULT:
I successfully simulated and veified the logic in the problem statement on Arduino Uno using
Tinkercad circuits simulator.

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 13


CHALLENGING TASK:
AIM: Write a program to design a traffic light controller system for a four lane junction (North, South,
East, West) to coordinate the traffic moves.
 Use 12 LEDs (3 for each direction) for traffic light signal indication
 In normal signalling operation, similar signal sequence are applied in opposite lanes (for ex. east and
west) with Green signal for 15 Sec. then Yellow for 2 Sec. and then Red. Meanwhile, north & south
lane will be at red.
 Once this sequence is completed, switch to next opposite lanes (i.e north & south) and carry out
signalling with Green signal for 10 Sec. then Yellow signal for 2 Sec. and then Red meanwhile, east
& west lane will be in red.
 Continuously switch between these two signal sequence.
API REQUIRED:
 pinMode(pin, mode) - Configures the specified pin to either input or output.
- pin: the Arduino pin number to set the mode of.
- mode: INPUT, OUTPUT, or INPUT_PULLUP.

 digitalWrite(pin, value) - Write a HIGH or a LOW value to a digital pin.


- pin: the Arduino pin number.
- value: HIGH or LOW.

 delay(ms) - Pauses the program for the amount of time (in milliseconds)
- ms: the number of milliseconds to pause.
PROGRAM:
int Lane1[] = {4,5,6}; // Lane 1 Red, Yellow and Green
int Lane2[] = {1,2,3};// Lane 2 Red, Yellow and Green
int Lane3[] = {4,5,6};// Lane 3 Red, Yellow and Green
int Lane4[] = {1,2,3};// Lane 4 Red, Yellow and Green

void setup()
{
for (int i = 0; i < 3; i++)
{
pinMode(Lane1[i], OUTPUT);
pinMode(Lane2[i], OUTPUT);
pinMode(Lane3[i], OUTPUT);

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 14


pinMode(Lane4[i], OUTPUT);
}
for (int i = 0; i < 3; i++)
{
digitalWrite(Lane1[i], LOW);
digitalWrite(Lane2[i], LOW);
digitalWrite(Lane3[i], LOW);
digitalWrite(Lane4[i], LOW);
}

void loop()
{
digitalWrite(Lane1[2], HIGH);
digitalWrite(Lane3[2], HIGH);
digitalWrite(Lane4[0], HIGH);
digitalWrite(Lane2[0], HIGH);
delay(15000);
digitalWrite(Lane1[2], LOW);
digitalWrite(Lane3[2], LOW);
digitalWrite(Lane1[1], HIGH);
digitalWrite(Lane3[1], HIGH);
delay(2000);
digitalWrite(Lane1[1], LOW);
digitalWrite(Lane3[1], LOW);
digitalWrite(Lane1[0], HIGH);
digitalWrite(Lane3[0], HIGH);
digitalWrite(Lane2[0], LOW);
digitalWrite(Lane4[0], LOW);
digitalWrite(Lane2[2], HIGH);
digitalWrite(Lane4[2], HIGH);
delay(10000);
digitalWrite(Lane2[2], LOW);
digitalWrite(Lane4[2], LOW);

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 15


digitalWrite(Lane2[1], HIGH);
digitalWrite(Lane4[1], HIGH);
delay(2000);
digitalWrite(Lane2[1], LOW);
digitalWrite(Lane4[1], LOW);
}
OUTPUT:

TINKERCAD LINK: https://www.tinkercad.com/things/1VUvAoj9W0a

INFERENCE:
I used pinMode(pin,mode) to specify output to the four leds and we use digitalWrite(pin,value) to
assign high/low value to the four leds as per the sequence of time described in the statement.

RESULT:
I successfully simulated and veified the logic in the problem statement on Arduino Uno using Tinkercad
circuits simulator.

[19BLC1137] ECE4003-Embedded System Design Lab Page No: 16

You might also like