0% found this document useful (0 votes)
3 views13 pages

ArduinoFileARSH 2

This document is a practical file for a semester 6 course on Arduino/Raspberry Pi app development at the University of Delhi. It includes five experiments demonstrating various applications of the Arduino Uno, such as blinking an LED, controlling an LED with a switch, designing an interactive LED with a push button, implementing a traffic light controller, and displaying a 4-bit binary count on LEDs. Each experiment outlines the aim, theory, setup, code, results, and learning outcomes.

Uploaded by

nodhairyajain
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)
3 views13 pages

ArduinoFileARSH 2

This document is a practical file for a semester 6 course on Arduino/Raspberry Pi app development at the University of Delhi. It includes five experiments demonstrating various applications of the Arduino Uno, such as blinking an LED, controlling an LED with a switch, designing an interactive LED with a push button, implementing a traffic light controller, and displaying a 4-bit binary count on LEDs. Each experiment outlines the aim, theory, setup, code, results, and learning outcomes.

Uploaded by

nodhairyajain
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

Faculty of Technology

University of Delhi

ARDUINO/ RPI APP DEVELOPMENT


Practical File
SEMESTER -6

Submitted To : Dr. Vandana Kumari

Submitted By : Arshdeep Singh


Batch : CSE - B
Enrollment : 23DOCEBTCS000140
Exam Roll : 23293916140
INDEX
S. No. Title Page No. Signature
1 2
To blink an LED and a buzzer using digital
output pins of the Arduino Uno.

2 4
To control an LED using a slide switch connected
to the Arduino Uno.

3 To design an interactive LED using push button 7


control.

4 9
To implement a traffic light controller using
Arduino Uno.

5 11
To display a 4-bit binary count on LEDs using
Arduino digital pins.
Experiment – 1
Aim:
To blink an LED and a buzzer using digital output pins of the Arduino Uno.

Theory:
Arduino Uno is a microcontroller board based on the ATmega328P.​
Its digital pins can be configured as OUTPUT to control external electronic components.

An LED emits light when a HIGH signal is applied, while a buzzer generates sound when driven by a
periodic electrical signal using the tone() function.​
By alternately switching the digital pins HIGH and LOW with a fixed delay, blinking of the LED and
sound generation of the buzzer can be achieved.

Setup for the Experiment:


●​ Arduino Uno (Simulation using Wokwi)
●​ LED connected to digital pin 5
●​ Buzzer connected to digital pin 6
●​ Current-limiting resistor
●​ Jumper wires

Code:

const int buzzer = 6;


const int led = 5;
void setup() {
// put your setup code here, to run once:
pinMode(buzzer, INPUT);
pinMode(led, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(buzzer, HIGH);
digitalWrite(led, HIGH);
tone(buzzer, 100);
delay(1000);
digitalWrite(buzzer, LOW);
digitalWrite(led, LOW);
noTone(buzzer);
delay(1000);
}
Simulations / Results:

Figure 1: Circuit diagram showing LED and buzzer connected to Arduino Uno in Wokwi

Result:​
The LED and buzzer turn ON and OFF alternately with a delay of one second, confirming correct digital
output control.

Learning Outcomes:
●​ Understood working of Arduino digital output pins
●​ Learned to interface LED and buzzer
●​ Gained experience with timing and sound generation functions
Experiment – 2
Aim:
To control an LED using a slide switch connected to the Arduino Uno.

Theory:
A slide switch acts as a digital input device.​
In this experiment, the common terminal of the slide switch is connected to GROUND.

When the slider is:

●​ Moved to the left → the switch pin is connected to GROUND → input becomes LOW
●​ Moved to the right → the pin is disconnected → input becomes HIGH

Since the switch pin is configured as INPUT_PULLUP, Arduino enables an internal pull-up resistor.​
This removes the need for an external resistor and ensures a stable input.

The LED state is directly controlled by the switch state using digitalWrite().

Setup for the Experiment:


●​ Arduino Uno (Simulation using Wokwi)
●​ LED connected to digital pin 13
●​ Slide switch connected to digital pin 3
●​ Common terminal of switch connected to GND
●​ Internal pull-up resistor enabled

Code:
// The common contact of the slide switch is connected
// to the GROUND by sliding the slider to the left,
// so the pin value at switch_pin becomes LOW.
// In contrast, by sliding the slider of switch to the right,
// it is disconnected. Since we define switch_pin as INPUT_PULLUP,
// it is read as HIGH if the pin is disconnected.

const int LED_pin = 13, switch_pin = 3;

void setup() {
pinMode(LED_pin, OUTPUT);
pinMode(switch_pin, INPUT_PULLUP);
}

void loop() {
int switch_state = digitalRead(switch_pin);
digitalWrite(LED_pin, switch_state);
}
Simulations / Results:

Figure 1: Circuit diagram showing LED and slide switch connection in Arduino Uno (Wokwi)

Figure 2: Output showing LED ON when switch is in HIGH position


Result:​
The LED and buzzer turn ON and OFF alternately with a delay of one second, confirming correct digital
output control.

Learning Outcomes:
●​ Understood working of Arduino digital output pins
●​ Learned to interface LED and buzzer
●​ Gained experience with timing and sound generation functions
Experiment – 3
Aim:

To design an interactive LED using push button control.

Theory:
A push button is a momentary input device that provides input only when pressed.​
When configured with INPUT_PULLUP, the Arduino detects a LOW signal upon button press.

The LED responds instantly to the button state, enabling interactive control.

Setup for the Experiment:


●​ Arduino Uno (Simulation using Wokwi)
●​ Push button connected to digital pin 2
●​ LED connected to digital pin 13
●​ Internal pull-up resistor enabled

Code:
const int buttonPin = 2;
const int ledPin = 13;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
int buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
Simulations / Results:

Figure 1: Circuit diagram of push button and LED

Result:​
The LED glows only while the push button is pressed.

Learning Outcomes:
●​ Understood push button operation
●​ Implemented real-time interaction
●​ Strengthened digital input concepts
Experiment – 4
Aim:
To implement a traffic light controller using Arduino Uno.

Theory:
A traffic light controller operates on sequential timing logic.​
Red, Yellow, and Green lights are activated for predefined durations to regulate traffic flow.

Arduino digital pins are programmed using delays and loops to simulate real-world traffic light behavior.

Setup for the Experiment:


●​ Arduino Uno (Simulation using Wokwi)
●​ Red LED connected to pin 0
●​ Yellow LED connected to pin 1
●​ Green LED connected to pin 2
●​ Resistors and jumper wires

Code:
void setup() {
// put your setup code here, to run once:
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
delay(5000);

digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
delay(2000);

digitalWrite(0, LOW);
digitalWrite(1,HIGH);
digitalWrite(2, HIGH);
delay(5000);

int t = 1;
while (t < 5){
t = t+1;
digitalWrite(0, HIGH);
digitalWrite(1,HIGH);
digitalWrite(2, HIGH);
delay(300);

digitalWrite(0, LOW);
digitalWrite(1,HIGH);
digitalWrite(2, HIGH);
delay(300);
}

Simulations / Results:

Figure 1: Circuit diagram of traffic light controller

Result:​
The LEDs follow the correct traffic light sequence with proper timing.

Learning Outcomes:
●​ Learned sequential control of outputs
●​ Applied delay-based timing logic
●​ Understood real-world control systems
Experiment – 5
Aim:
To display a 4-bit binary count on LEDs using Arduino digital pins.

Theory:
Binary numbers use base-2 representation consisting of bits (0 and 1).​
A 4-bit binary counter can represent decimal values from 0 to 15.

Each LED represents one bit. The Arduino uses bitwise operations to convert decimal numbers into
binary and display them through LEDs.

Setup for the Experiment:


●​ Arduino Uno (Simulation using Wokwi)
●​ LEDs connected to pins 2, 4, 6, and 8
●​ Current-limiting resistors
●​ Jumper wires

Code:
#define BIT_0_PIN 2
#define BIT_1_PIN 4
#define BIT_2_PIN 6
#define BIT_3_PIN 8

#define DELAY_TIME 1500

int bits[4] = {BIT_0_PIN, BIT_1_PIN, BIT_2_PIN, BIT_3_PIN};

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

void loop() {
int value;
for (value = 0; value < 16; value++) {
showBinary(value);
delay(DELAY_TIME);
}
}

void showBinary(int value) {


int i;
for (i = 0; i < 4; i++) {
if (value & (1 << i)) {
digitalWrite(bits[i], HIGH);
} else {
digitalWrite(bits[i], LOW);
}
}
}

Simulations / Results:

Figure 1: Circuit diagram of 4-bit binary counter

Result:​
The LEDs display a continuous binary count from 0 to 15 with a delay of 1.5 seconds.

Learning Outcomes:
●​ Understood binary number system
●​ Learned bitwise operations
●​ Implemented multi-LED control

You might also like