Csed MST Baw

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

A MST Practical

File Report
Submitted For
Engineering Design Project - II (UTA-024)

Submitted by:

102383014 Hrithik Jerath


102203959 Srishti Duggal
102203084 Hardik Sharma
102203110 Prisha
102203823 Sanyam

BE Second Year (COE)


Batch - 2026

Submitted to -
Mr . Gurpreet Singh

Computer Science And Engineering Department


TIET, Patiala
Jan - May 2024

1
TABLE OF CONTENTS

Abstract i
Declaration ii
Table of Contents iii
List of Tables iv
List of Figures v
List of Abbreviations vi

2
Abstract

This report contains the use of Arduino Uno to perform various experiments. We used
Arduino IDE software to write different codes, which were used in performing various
experiments. We used Arduino Uno, breadboard, LEDs, probe/connecting wires, and other
various components to make multiple circuits and execute the codes to see the results.

3
Declaration

● We, the undersigned, solemnly declare that the project report EST PRACTICAL
ACTIVITY REPORT is based on our work carried out during our study under the
supervision of Mr. Gurpreet Singh.

● We assert the statements made and conclusions drawn are an outcome


of our own research work. We further certify that

● The work contained in the report is original and has been done by
us under the general supervision of our supervisor.

● The work has not been submitted to any other Institution for any
other degree/diploma/certificate in this university or any other
University in India or abroad.

● We have followed the guidelines provided by the university in writing the report.

● Whenever we have used materials (data, theoretical analysis, and text) from other
sources, we have given due credit to them in the report's text and their details in
the references.

4
LIST OF TABLES

Table No. Caption Page No.

Table 1 Experiment 1 8

Table 2 Experiment 2 10

Table 3 Experiment 3 13

Table 4 Experiment 4 20

Table 5 Experiment 5 24

Table 6 Experiment 6 30

Table 7 Experiment 7 33

Table 8 Experiment 8 35

Table 9 Experiment 9 39

Table 10 Experiment 10 44

Table 11 Experiment 11 47

5
LIST OF FIGURES

Figure No. Caption Page No.

Figure 1.1 Arduino 8

Figure 2.1 Circuit Diagram 11

Figure 3.1 Circuit Diagram 13

Figure 4.1 Circuit Diagram 19

Figure 5.1 Circuit Diagram 22

Figure 6.1 Arduino 25

Figure 6.2 Output Serial Monitor 27

Figure 7.1 Arduino 28

Figure 7.2 Output Serial Monitor 29

Figure 8.1 Circuit Diagram 31

Figure 9.1 Circuit Diagram 34

Figure 10.1 Arduino 37

Figure 10.2 Buggy 37

Figure 11.1 Circuit Diagram 41

6
INDEX

S. Name of Experiments
No.
1 Introduction to Arduino Micro-Controller.
2 To make a circuit for blinking an LED using Arduino Uno and breadboard.

3 Write an Arduino program to blink multiple LEDs using: While loop, Array, Switch Case, If
else, Function.
4 Write an Arduino program to design an odd-even pattern and perform the reverse operation.
For example- Sequence = 1 3 5 2 4--- 4 2 5 3 1
5 Develop a program to blink five LEDs with five distinct patterns, each implemented in a
separate function using analogWrite. Describe each pattern in your code.

6 Introduction to the serial monitor

7 WAP to print the following pattern: (Use string read function)


****************************
Name-
****************************
Class-
****************************
Roll No.
***************************
8 Write an Arduino program that takes data from a serial monitor and uses it to control the
brightness, number of blinks, and which LED blinks.
9 Write a program for virtual LED Dice using a random function.

10 WAP to perform the following movements of Robo Car (Buggy): forward, backward, left,
right, clockwise and anti-clockwise motion. (Use a function for each)
11 Write a program that visually displays binary inputs taken up to 2^5 on 5 LEDs through serial
communication. (Take input trough serial communication)

7
5. PWM – The pins marked with the (~) symbol can simulate analog output.
6. USB Connection – Used for powering up your Arduino and uploading sketches.

7. TX/RX – Transmit and receive data indication LEDs.

8. ATmega Microcontroller – This is the brains and is where the programs are stored 9.
Power LED Indicator – This LED lights up anytime the board is plugged in a power
source.

10. Voltage Regulator – This controls the amount of voltage going into the Arduino
board.

11. DC Power Barrel Jack – This is used for powering your Arduino with a power
supply.

12. 3.3V Pin – This pin supplies 3.3 volts of power to your projects.

13. 5V Pin – This pin supplies 5 volts of power to your projects.

14. Ground Pins – There are a few ground pins on the Arduino and they all work the
same.

15. Analog Pins – These pins can read the signal from an analog sensor and convert it to
digital.

DISCUSSIONS

In this experiment, we get to know about basics of Arduino Uno Microcontroller and its various
functions and components.

Signature of faculty member

9
EXPERIMENT-2
OBJECTIVE: Write a program to blink a single LED using Arduino and breadboard.
SOFTWARE USED: Tinkercad Simulator.
HARDWARE USED:

Sr No. Name of the Component Value

1. Arduino Uno Board 1

2. Breadboard 1

3. Jumper Wires 5

4. LED 1

5. Resistor 220 ohm

THEORY:

Resistor: Resistors are used in virtually all electronic circuits and many electrical ones.
Resistors, as their name indicates resist the flow of electricity and this function is key to the
operation most circuits.

LED: A light-emitting diode (LED) is a semiconductor light source that emits light when
current flows through it. Electrons in the semiconductor recombine with electron holes,
releasing energy in the form of photons (Energy packets).

Arduino UNO Board: The Arduino UNO is an open-source microcontroller board based on
the Microchip ATmega328P microcontroller and developed by Arduino. cc.

Breadboard: A breadboard is used to place components (resistor, capacitor, LED etc.) that are
wired together. It is used to make temporary circuits.

Jumper Wires: A jumper wire is an electric wire that connects remote electric circuits used
for printed circuit boards.

10
EXPERIMENT-3

OBJECTIVE: To blink multiple LEDs using Arduino Uno and breadboard. Using for loop,
while loop, array, switch case, functions.

SOFTWARE USED: Tinkercad Simulator.

HARDWARE USED:

Sr No. Name of the Component Value

1. Arduino Uno Board 1

2 Breadboard 1

3. Jumper Wires 10

4. LED 4

5. Resistor 4 X 220 ohm

THEORY:

Resistor: Resistors are used in virtually all electronic circuits and many electrical ones.
Resistors, as their name indicates resist the flow of electricity and this function is key to the
operation most circuits.

LED: A light-emitting diode (LED) is a semiconductor light source that emits light when
current flows through it. Electrons in the semiconductor recombine with electron holes,
releasing energy in the form of photons (Energy packets).

Arduino Uno Board: The Arduino Uno is an open-source microcontroller board based on the
Microchip ATmega328P microcontroller and developed by Arduino.cc.

Breadboard: A breadboard is used to place components (resistor, capacitor, LED’s etc.) that
are wired together. It is used to make temporary circuits.

Jumper Wires: A jumper wire is an electric wire that connects remote electric circuits used
for printed circuit boards.

12
CODE:
//To Blink Multiple LED’s using:
1. For loop
2. While loop
3. Array
4. Switch case
5. Function

1) For loop
void setup()
{
for(int i=5;i<=8;i++)
{
pinMode(i, OUTPUT);
}
}
void loop()
{
for(int i =5;i<=8;i++)
{

digitalWrite(i, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(i, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
}

2) While loop
void setup()
{
for(int i=5;i<=8;i++)
{
pinMode(i, OUTPUT);
}
}

void loop()
{
int i=5;
while(i<=8)
{

digitalWrite(i, HIGH);
delay(1000);

14
digitalWrite(i, LOW);
delay(1000);
i++;
}
}

3) Array

int A[] = {5,6,7,8};//Pins to be used


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

void loop()
{

for(int i=0;i<=4;i++)
{

digitalWrite(A[i], HIGH);
delay(1000);
digitalWrite(A[i], LOW);
delay(1000);

}
}

4) Switch case

void setup()
{
for(int i=5;i<=8;i++)
{
pinMode(i, OUTPUT);
}
}

void loop()
{
int i=5;
while(true)

15
{

switch(i)
{
case 5:
digitalWrite(i, HIGH);
delay(1000);
digitalWrite(i, LOW);
delay(1000);
i++;
break;
case 6:
digitalWrite(i, HIGH);
delay(1000);
digitalWrite(i, LOW);
delay(1000);
i++;
break;
case 7:
digitalWrite(i, HIGH);
delay(1000);
digitalWrite(i, LOW);
delay(1000);
i++;
break;
case 8:
digitalWrite(i, HIGH);
delay(1000);
digitalWrite(i, LOW);
delay(1000);
i++;
break;
default:
i=5;

}
}

5) Function

void setup()
{
for(int i=5;i<=8;i++)

16
{
pinMode(i, OUTPUT);
}
}
void blinkLED(int i)
{
digitalWrite(i,HIGH);
delay(1000);
digitalWrite(i,LOW);
delay(1000);
}

void loop()
{
blinkLED(5);
blinkLED(6);
blinkLED(7);
blinkLED(8);

RESULTS:

In this experiment, we learnt how to blink multiple LEDs using Arduino Uno and breadboard.

Signature of faculty member

17
EXPERIMENT-4

OBJECTIVE: Write an Arduino program to design an odd-even pattern and perform the
reverse operation. For example- Sequence = 1 3 5 2 4--- 4 2 5 3 1

SOFTWARE USED: Tinkercad Simulator.

HARDWARE USED:

Sr No. Name of the Component Value

1. Arduino Uno Board 1

2. Breadboard 1

3. Jumper Wires 5

4. LED 1

5. Resistor 220 ohm

THEORY:
Resistor: Resistors are used in virtually all electronic circuits and many electrical ones.
Resistors, as their name indicates, resist the flow of electricity and this function is key to the
operation of most circuits.

LED: A light-emitting diode (LED) is a semiconductor light source that emits light when
current flows through it. Electrons in the semiconductor recombine with electron holes,
releasing energy as photons (Energy packets).

Arduino Uno Board: The Arduino Uno is an open-source microcontroller board based on the
Microchip ATmega328P microcontroller and developed by Arduino. cc.

Breadboard: A breadboard is used to place components (resistor, capacitor, LED’s etc.) that
are wired together. It is used to make temporary circuits.

Jumper Wires: A jumper wire is an electric wire that connects remote electric circuits used
for printed circuit boards.

18
}
}

// Reverse the pattern sequence


for (int i = 4; i >= 2; i -= 2) {
if (i % 2 == 0) {
digitalWrite(ledPin, HIGH); // Turn on LED
delay(500);
digitalWrite(ledPin, LOW); // Turn off LED
delay(500);
}
}

for (int i = 5; i >= 1; i--) {


if (i % 2 == 1) {
digitalWrite(ledPin, HIGH); // Turn on LED
delay(500);
digitalWrite(ledPin, LOW); // Turn off LED
delay(500);
}
}
}

RESULTS:
In this experiment, we learnt how to demonstrate sending data from the computer to the
Arduino board and control brightness of LED.

Signature of faculty member

20
EXPERIMENT-5

OBJECTIVE: Develop a program to blink five LEDs with five distinct patterns, each
implemented in a separate function using analogWrite. Describe each pattern in your code.

SOFTWARE USED: Tinkercad Simulator.

HARDWARE USED:

Sr No. Name of the Component Value

1 Arduino Uno Board 1

2 Breadboard 1

3 Jumper Wires 5

4 LED 1

5 Resistor 220 ohm

THEORY:

Arduino Uno Board: The Arduino Uno is an open-source microcontroller board based on the
Microchip ATmega328P microcontroller developed by Arduino. cc.

Resistor: Resistors are used in virtually all electronic and electrical circuits. Resistors, as their
name indicates, resist the flow of electricity and this function is key to the operation of most
circuits.

LED: A light-emitting diode (LED) is a semiconductor light source that emits light when
current flows through it. Electrons in the semiconductor recombine with electron holes,
releasing energy in the form of photons (Energy packets).

Breadboard: A breadboard is used to place components (resistor, capacitor, LED etc.) that are
wired together. It is used to make temporary circuits.

Jumper Wires: A jumper wire is an electric wire that connects remote electric circuits used
for printed circuit boards.

21
CODE:
int Pins[] = {9, 10, 11, 12, 13}; // Pins connected to LEDs

void setup() {
for (int i = 0; i < 5; i++) {
pinMode(Pins[i], OUTPUT); // Initialize LED pins as outputs
}
}

void loop() {
pattern1(); // Call pattern 1
delay(1000); // Wait for 1 second

pattern2(); // Call pattern 2


delay(1000); // Wait for 1 second

pattern3(); // Call pattern 3


delay(1000); // Wait for 1 second

pattern4(); // Call pattern 4


delay(1000); // Wait for 1 second

pattern5(); // Call pattern 5


delay(1000); // Wait for 1 second
}

// Pattern 1: Blink all LEDs simultaneously


void pattern1() {
for (int i = 0; i < 5; i++) {
analogWrite(Pins[i], 255); // Turn on LED at full brightness
}
delay(500); // Wait for 0.5 seconds
for (int i = 0; i < 5; i++) {
analogWrite(Pins[i], 0); // Turn off LED
}
}

// Pattern 2: Sequentially blink each LED


void pattern2() {
for (int i = 0; i < 5; i++) {
analogWrite(Pins[i], 255); // Turn on LED at full brightness
delay(200); // Wait for 0.2 seconds
analogWrite(Pins[i], 0); // Turn off LED
}
}

// Pattern 3: Alternately blink odd and even numbered LEDs

23
void pattern3() {
for (int i = 0; i < 5; i += 2) {
analogWrite(Pins[i], 255); // Turn on LED at full brightness
}
delay(500); // Wait for 0.5 seconds
for (int i = 0; i < 5; i += 2) {
analogWrite(Pins[i], 0); // Turn off LED
}
delay(500); // Wait for 0.5 seconds
for (int i = 1; i < 5; i += 2) {
analogWrite(Pins[i], 255); // Turn on LED at full brightness
}
delay(500); // Wait for 0.5 seconds
for (int i = 1; i < 5; i += 2) {
analogWrite(Pins[i], 0); // Turn off LED
}
}

// Pattern 4: Blink LEDs in a wave-like pattern


void pattern4() {
for (int i = 0; i < 5; i++) {
analogWrite(Pins[i], 255); // Turn on LED at full brightness
delay(200); // Wait for 0.2 seconds
analogWrite(Pins[i], 0); // Turn off LED
}
for (int i = 3; i >= 0; i--) {
analogWrite(Pins[i], 255); // Turn on LED at full brightness
delay(200); // Wait for 0.2 seconds
analogWrite(Pins[i], 0); // Turn off LED
}
}

// Pattern 5: Blink LEDs in a chasing pattern


void pattern5() {
for (int i = 0; i < 5; i++) {
analogWrite(Pins[i], 255); // Turn on LED at full brightness
delay(200); // Wait for 0.2 seconds
analogWrite(Pins[i], 0); // Turn off LED
}
}

RESULTS: In this experiment we studied how to make different led patterns using functions
in Arduino programming.

Signature of faculty member

24
interface where users can send commands to turn on/off LEDs, adjust motor speeds, or
change other parameters.

4. Configuration: Some Arduino projects may require configuration settings to be


adjusted at runtime. By using the Serial Monitor, you can provide a user-friendly
interface for adjusting these settings without having to re-upload your sketch.

How to use the Serial Monitor:

1. Ensure that your Arduino board is connected to your computer via USB.
2. Open the Arduino IDE.
3. Upload your sketch to the Arduino board.
4. Click on the "Serial Monitor" button in the Arduino IDE toolbar, or navigate to Tools
> Serial Monitor.
5. Set the baud rate in the bottom right corner of the Serial Monitor to match the baud rate
specified in your Arduino sketch (Serial.begin()).
6. You should now see the Serial Monitor window, where you can send and receive text
data.

CODE:
void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println("ArduinoGetStarted");
delay(1000);
}

RESULTS:

In this experiment, The Serial Monitor is an invaluable tool for Arduino development, enabling
you to interact with your Arduino projects and debug your code effectively.

26
void loop() {

if (Serial.available() > 0){

String name = Serial.readStringUntil(' ');

String class_1 = Serial.readStringUntil(' ');

String rollno = Serial.readStringUntil(' ');

printAsterisks();

Serial.println("Name-"); Serial.println(name);

printAsterisks();

Serial.println("Class-");Serial.println(class_1);

printAsterisks();

Serial.println("Roll No.");Serial.println(rollno);

printAsterisks();

delay(5000);

void printAsterisks() {

Serial.println("****************************");

RESULTS:
In this experiment, we learnt print the following pattern

Signature of faculty member

29
EXPERIMENT-8
OBJECTIVE: Write an Arduino program that takes data from a serial monitor and uses it to
control the brightness, number of blinks, and which LED blinks.

SOFTWARE USED: Tinkercad Simulator.


HARDWARE USED:

Sr No . Name of the Component Value

1 Arduino Uno Board 1

2 Breadboard 1

3 Jumper Wires 15

4 LED 5

5 Resistor 5 x 220-ohm

THEORY:
Resistor: Resistors are used in virtually all electronic circuits and many electrical ones.
Resistors, as their name indicates resist the flow of electricity and this function is key to the
operation most circuits.

LED: A light-emitting diode (LED) is a semiconductor light source that emits light when
current flows through it. Electrons in the semiconductor recombine with electron holes,
releasing energy in the form of photons (Energy packets).

Arduino Uno Board: The Arduino Uno is an open-source microcontroller board based on the
Microchip ATmega328P microcontroller and developed by Arduino. cc.

Breadboard: A breadboard is used to place components (resistor, capacitor, LED etc.) that are
wired together. It is used to make temporary circuits.

Jumper Wires: A jumper wire is an electric wire that connects remote electric circuits used
for printed circuit boards.

30
CODE:
void setup(){
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(9,OUTPUT);
}

void loop() {

// put your main code here, to run repeatedly:


int bright =0;
int LED =0;
if (Serial.available()>0)
{

//Serial.println("Hello");
LED=Serial.parseInt();
bright = Serial.parseInt();
int times = Serial.parseInt();
for(int i = 0;i<times;i++)
analogWrite(LED,bright);
delay(1000);
analogWrite(LED,0);
delay(1000);
}

RESULTS:
In this experiment, how Arduino takes data from a serial monitor and uses it to control the
brightness, number of blinks, and which LED blinks.

Signature of faculty member

32
EXPERIMENT-9

OBJECTIVE: Write a program for virtual LED Dice using a random function
SOFTWARE USED: Tinkercad Simulator.
HARDWARE USED:

Sr No. Name of the Component Value

1 Arduino Uno Board 1

2 Breadboard 1

3 Jumper Wires 15

4 LED 5

5 Resistor 5 x 220-ohm

THEORY:
Resistor: Resistors are used in virtually all electronic circuits and many electrical ones.
Resistors, as their name indicates resist the flow of electricity and this function is key to the
operation most circuits.

LED: A light-emitting diode (LED) is a semiconductor light source that emits light when
current flows through it. Electrons in the semiconductor recombine with electron holes,
releasing energy in the form of photons (Energy packets).

Arduino Uno Board: The Arduino Uno is an open-source microcontroller board based on the
Microchip ATmega328P microcontroller and developed by Arduino.cc.

Breadboard: A breadboard is used to place components (resistor, capacitor, LED’s etc.) that
are wired together. It is used to make temporary circuits.

Jumper Wires: A jumper wire is an electric wire that connects remote electric circuits used
for printed circuit boards.

33
CODE:
int A[] = {3,5,6,9,10,11,12};
void setup()
{
for (int i=0;i<7;i++){
pinMode(A[i],OUTPUT);
}
pinMode(2,INPUT); // Roll button
Serial.begin(9600);
}

void loop()
{
int number = 0;
for(int i =0;i<7;i++){
digitalWrite(A[i],LOW);
}
if(digitalRead(2)==HIGH)
{ number = random(1,7);
}
switch(number)
{
case 1:
digitalWrite(A[0],HIGH);
break;
case 2:
digitalWrite(A[1],HIGH);
break;
case 3:
digitalWrite(A[2],HIGH);
break;
case 4:
digitalWrite(A[4],HIGH);
break;
case 5:
digitalWrite(A[5],HIGH);
break;
case 6:
digitalWrite(A[6],HIGH);
break;
default:
digitalWrite(A[3],HIGH);
break;
}

35
delay(2000);
}
RESULTS:
In this experiment, we learnt virtual LED Dice using a random function

Signature of faculty member

36
CODE:
void setup(){
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);

}
void forward()
{
digitalWrite(5,HIGH);
digitalWrite(8,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
}
void backward()
{
digitalWrite(5,LOW);
digitalWrite(8,LOW);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
}
void clockwise()
{
digitalWrite(5,LOW);
digitalWrite(8,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,LOW);
}
void anticlockwise()
{
digitalWrite(5,HIGH);

digitalWrite(8,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
}
void lowall()
{
digitalWrite(5,LOW);
digitalWrite(8,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
}
void loop() {
clockwise();

38
delay(3000);
lowall();
delay(1000);
forward();
delay(10000);
}

RESULTS:
In this experiment, we learnt how to control of DC Motor using forward, backward, left, right
turn motion and clock- wise/anti clock- wise rotation.

Signature of faculty member

39
EXPERIMENT-11

OBJECTIVE: Write a program that visually displays binary inputs taken up to 2^5 on 5 LEDs
through serial communication. (Take input trough serial communication)
SOFTWARE USED: Tinkercad Simulator.
HARDWARE USED:

Sr No. Name of the Component Value

1 Arduino Uno Board 1

2 Breadboard 1

3 Jumper Wires 15

4 LED 5

5 Resistor 5 x 220-ohm

THEORY:
Resistor: Resistors are used in virtually all electronic circuits and many electrical ones.
Resistors, as their name indicates resist the flow of electricity and this function is key to the
operation most circuits.

LED: A light-emitting diode (LED) is a semiconductor light source that emits light when
current flows through it. Electrons in the semiconductor recombine with electron holes,
releasing energy in the form of photons (Energy packets).

Arduino Uno Board: The Arduino Uno is an open-source microcontroller board based on the
Microchip ATmega328P microcontroller and developed by Arduino.cc.

Breadboard: A breadboard is used to place components (resistor, capacitor, LED’s etc.) that
are wired together. It is used to make temporary circuits.

Jumper Wires: A jumper wire is an electric wire that connects remote electric circuits used
for printed circuit boards.

40
CODE:
int A[]={3,5,6,9,10};
void setup()
{
for(int i =0;i<5;i++)
{
pinMode(A[i], OUTPUT);
}
Serial.begin(9600);
}
void loop()
{
int LED=0;
int Bright = 0;
if(Serial.available()>0)
{
//LED = Serial.parseInt();
//Bright = Serial.parseInt();
int number = 0;
number = Serial.parseInt();
int a,b,c,d,e;
a = (number/1)%2;//3
b = (number/2)%2;//5
c = (number/4)%2;//6
d = (number/8)%2;//10
e = (number/16)%2;//11

digitalWrite(3,a);
digitalWrite(5,b);
digitalWrite(6,c);
digitalWrite(10,d);
digitalWrite(11,e);
}

RESULTS:
In this experiment, binary inputs taken up to 2^5 on 5 LEDs through serial communication.
(Take input trough serial communication)

Signature of faculty member

42

You might also like