Professional Documents
Culture Documents
Submitted by 19Blc1137 - Saksham Mishra Submitted To Dr. Manoj Kumar Rajagopal
Submitted by 19Blc1137 - Saksham Mishra Submitted To Dr. Manoj Kumar Rajagopal
Submitted By
19BLC1137 – SAKSHAM MISHRA
Submitted To
Dr. Manoj Kumar Rajagopal
DATE: 04/08/2021
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.
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()
{
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:
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.
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.
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++)
}
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:
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.
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.
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);
void loop()
{
SWITCHSTATE = digitalRead(SWITCH);
if (SWITCHSTATE == HIGH)
{
digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
delay(10000);
}
else
{
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
}
}
OUTPUT:
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.
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.
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);
}
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.
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);
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);
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.