Experiment with a Button Switch Module

buttonswitch 1

How to use PCB mounted pushButton

A built-in 10 K ohm resistor is connected between the center pin and the ‘S’ pin . This
can be used as a pull up or pull down resistor. The push button connects the two
outer pins.

First of all you will Need:

(1)x Uno R3
(1)x USB cable
(1) x Button module
(x) x F-M wires

PUSH SWITCHES:
Switches are really simple components. When you press a button or flip a lever, they connect two contacts to get her so that electricity can flow through them.

Button Switch Module Connection
Button Switch Module Connection

In realety, there are only two electrical connections. The pins B and C are connected together, as are A and D.

Button switch and number 13 port have the built-in LED simple circuit. To produce a switch flasher, we can use connect the digital port 13 to the built-in LED and connect the button switch Sport to number 3 port of Uno board .When the switch sensing, LED twinkle light to the switch signal.

For instance, Here is the Wiring diagram

Wiring diagram for Button Switch Module
Wiring diagram for Button Switch Module

Connect the circuit as above and upload the program. Then push the button, as a result, you can see led go on and off.

Code

int Led = 13; //define LED port
int Shock = 3; //define shock port
int val;//define digital variable val
void setup()
{
pinMode(Led, OUTPUT); //define LED as a output port
pinMode(Shock, INPUT); //define shock sensor as a output port
}
void loop()
{ val = digitalRead(Shock); //read the value of the digital interface 3 assigned to val
if (val == HIGH) //when the shock sensor have signal, LED blink
{
digitalWrite(Led, LOW);
}
else
{
digitalWrite(Led, HIGH);
}
}

Show Buttons
Hide Buttons