Experiment 2 Push Button
Experiment 2 Push Button
2
Circuit Diagram
3
Connection Diagram
4
Program
Int v = 0;
void setup()
{
pinMode(13, OUTPUT);
pinMode(2, INPUT);
}
void loop()
{
v = digitalRead(2);
digitalWrite(13, v);
}
5
Program using if else Statements
#define LED 13
#define PUSHBUTTON 7
int Button_State = 0; // variable for reading the push button status
void setup(){
pinMode();
pinMode();
}
void loop(){
Button_State = digitalRead();
if (Button_State == HIGH) { // turn LED on:
statements;
}
else { //turn LED off
statements;
}
}
6
Self Assessment Questions
7
THANK YOU