Professional Documents
Culture Documents
Aim: To Interface Led, Buzzer and Two Push Buttons With Arduino Objectives
Aim: To Interface Led, Buzzer and Two Push Buttons With Arduino Objectives
Practical No. 5
Aim: To interface led, buzzer and two push buttons with Arduino
Objectives:
Theory:
LED: A light-emitting diode is a semiconductor light source that emits light when current
flows through it.
Push-button: a device designed to close or open an electric circuit when a button or knob is
pressed, and to return to a normal position when it is released.
Piezo Buzzer: a piezo buzzer is a type of electronic device that’s used to produce a tone,
alarm or sound.
tone():Generates a square wave of the specified frequency (and 50% duty cycle) on a pin. A
duration can be specified, otherwise the wave continues until a call to noTone(). The pin can
be connected to a piezo buzzer or other speaker to play tones.
Circuit Diagram:
1
Roll No:1253 IOT LAB
Program:
// C++ code
int buzzer = 3;
int buttonstate1 = 0;
int buttonstate2 = 0;
void setup()
pinMode(led,OUTPUT);
pinMode(buzzer,OUTPUT);
pinMode(button1,INPUT_PULLUP);
pinMode(button2,INPUT_PULLUP);
noTone(buzzer);
2
Roll No:1253 IOT LAB
void loop()
buttonstate1 = digitalRead(button1);
buttonstate2 = digitalRead(button2);
if(buttonstate1 == LOW)
digitalWrite(led,HIGH);
delay(2000);
digitalWrite(led,LOW);
delay(100);
if(buttonstate2 == LOW)
tone(buzzer,500);
delay(2000);
noTone(buzzer);
delay(100);
Output:
3
Roll No:1253 IOT LAB
Conclusion: Thus, learnt about basic components of IoT like Arduino UNO, Breadboard,
resisters, LED’s and interfacing LED with Arduino.
Practical No. 6
4
Roll No:1253 IOT LAB
Theory:
Circuit Diagram:
Program:
// C++ code
//
5
Roll No:1253 IOT LAB
int buttonstate1 = 0;
int buttonstate2 = 0;
int buttonstate3 = 0;
void setup()
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(button1,INPUT_PULLUP);
pinMode(button2,INPUT_PULLUP);
pinMode(button3,INPUT_PULLUP);
void loop()
buttonstate1 = digitalRead(button1);
buttonstate2 = digitalRead(button2);
buttonstate3 = digitalRead(button3);
if(buttonstate1 == LOW)
digitalWrite(led1,HIGH);
delay(1000);
digitalWrite(led1,LOW);
delay(100);
6
Roll No:1253 IOT LAB
if(buttonstate2 == LOW)
digitalWrite(led2,HIGH);
delay(1000);
digitalWrite(led2,LOW);
delay(100);
if(buttonstate3 == LOW)
digitalWrite(led3,HIGH);
delay(1000);
digitalWrite(led3,LOW);
delay(100);
Output:
7
Roll No:1253 IOT LAB
Conclusion: Thus, learnt about basic components of IoT like Arduino UNO, Breadboard,
resisters, LED’s and interfacing LED with Arduino.