0% found this document useful (0 votes)
30 views5 pages

Exp 2

Uploaded by

mischiff305
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)
30 views5 pages

Exp 2

Uploaded by

mischiff305
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
You are on page 1/ 5

Experiment No: 2

Interfacing External LED and Buzzer

Name of the Student:- Sujal Sanjay Dubey Div: - CS-AIML Roll No: - SEDA 06

Aim: To interface external LED and Buzzer to Node MCU


Components Required:

1) Node MCU – 1
2) Micro USB Cable – 1
3) PC/Laptop – 1
4) Connecting Wires
5) Bread Board – 1
6) LED – 4
7) Buzzer -1
8) Resistor 200 Ohm – 1

Software Required:

Arduino IDE

Theory:

We are familiar with blinking LED using Arduino boards as this is the fundamental step towards
using a new development board. In this experiment, first we will see how to connect an external
LED with Node MCU and how to blink it using GPIO pins of ESP8266 Node MCU. After that
we will see how to connect buzzer with Node MCU.

Procedure:

1. Blinking External LED

Step 1: Make the circuit diagram on bread board according to connection diagram shown below.
Anode of the LED [long leg of the LED] is connected to the D1 pin of the Node MCU, the cathode
of the LED [short leg of the LED] is connected with the one terminal of the resistor [200 Ohm]
and another terminal of the resistor is connected to the ground pin.
1
Step 2: Connect Node MCU to PC / Laptop with the help of micro USB cable

Step 3: Open new Sketch, Go to file ---- > New

Step 4: Write following code in new sketch

// the setup function runs once when you press reset or power the board

void setup() {

pinMode(D1, OUTPUT); // initialize digital pin LED_BUILTIN as an output.


}
// the loop function runs over and over again forever
void loop() {
digitalWrite(D1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(D1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Step 5: Save the new sketch by appropriate name in a folder on your PC / Laptop

Step 6: Upload the sketch on Node MCU. Go to Sketch ---- > Upload

Step 7: Observe the output [Blinking External LED]


2
2. Connecting Buzzer

Step 1: Make the circuit diagram on bread board according to connection diagram shown below.
Positive terminal of buzzer [long leg of the buzzer] is connected to the D5 pin of the Node MCU,
negative terminal of buzzer [short leg of the buzzer] is connected to the ground pin.

Step 2: Connect Node MCU to PC / Laptop with the help of micro USB cable

Step 3: Open new Sketch, Go to file ---- > New

Step 4: Write following code in new sketch

void setup()
{
}
void loop()
{
tone(14, 494, 500);
delay(1000);
}

The three numbers inside the tone() function represent: the pin we send the sound (D5 or 14 in
our case), the frequency of the sound wave we send and the duration of the tone.
3
You can change the last two parameters and play with the speed of the beeps and the sound of
them.

Step 5: Save the new sketch by appropriate name in a folder on your PC / Laptop

Step 6: Upload the sketch on Node MCU. Go to Sketch ---- > Upload

Step 7: Observe the output

Practice:

1. Connect 2/3/4 External LEDs and try different patterns of dancing LEDs
2. In tone function, use different music notes with different time period and run the melody.

Snapshots of Lab Performance:

1. External LED Interface

4
2. Buzzer Interface

Conclusion:

In conclusion, the experiment to interface an external LED and buzzer to a Node MCU was
successful in providing hands-on experience in combining hardware and software to control
external components. It serves as a crucial building block for future IoT and embedded systems
projects, where the ability to interface various sensors and actuators is essential. Participants
gained valuable skills in electronics, microcontroller programming, and project development
through this experiment.

You might also like