0% found this document useful (0 votes)
6 views3 pages

Second IOT Record

Uploaded by

NITHISH PU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Second IOT Record

Uploaded by

NITHISH PU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

6-BTCS-B 2260406

Exp 2: To Implement Buzzer Activation Through


LED Input
Date :

Aim Of The Experiment:


The aim of this experiment is to design and implement a system where the
activation of a buzzer is controlled by the state of an LED. Specifically, the
objective is to ensure that when the LED is turned on, the buzzer is turned off,
and conversely, when the buzzer is activated, the LED is turned off. This
functionality will be achieved through appropriate circuit design and
programming using an Arduino microcontroller.

Components/Software Required:
– Buzzer .
– 1 Yellow LED {Light Emitting Diode}.
– Jumper Wires.
– Arduino Uno.
– Breadboard.

Procedure:
1. Gather components: Arduino board, buzzer, LED, resistor (220 ohms),
and jumper wires.
2. Connect the LED to a digital pin (e.g., pin 9) with a resistor to ground;
connect the buzzer to another digital pin (e.g., pin 8) and ground.
3. Power the Arduino by connecting it to a power source via USB or
external power.
4. In the Arduino IDE, write a program to turn on the LED when the buzzer
is off and vice versa.
5. Connect the Arduino to your computer and upload the code using the
IDE.
6. Activate the LED and check that the buzzer is off; then activate the
buzzer and ensure the LED turns off.
7. If issues arise, check connections, pin assignments, and component
functionality.
6-BTCS-B 2260406

Code:

// C++ code
//
const int buzzer = 11;
const int LED = 8;//buzzer to arduino pin 9

void setup(){
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
pinMode(LED,OUTPUT);
Serial.println("Enter the State");
String state = Serial.readString();// Set buzzer - pin 9 as an output

}
void loop(){

String state = Serial.readString();


if(state == "ON"){
digitalWrite(LED,0);
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(1000); // ...for 1 sec
noTone(buzzer); // Stop sound...
delay(1000);

}
else{
digitalWrite(LED,1)
}
}

Results:
6-BTCS-B 2260406

You might also like