Arduino Push Button Switch Module
Keyes KY-004 Key Switch Module is a simple on/off Micro switch compatible with Arduino systems.
The module consists of an FZ1713 touch button switch and a resistor. Compatible with popular electronic platforms such as Arduino, Raspberry Pi and Esp8266.
Technical Specifications:
Operating voltage: 5V
Length: 25mm
Width: 16mm
Height: 10mm
Weight: 1.5g
Ambient temperature -25°C to 105°C
Electrical life 100,000 cycles
Operating Force 180/230 (± 20gf)
Arduino Connection
Sample Arduino Code
When the button on KY-004 is pressed, the following code will turn on the Arduino pin 13 LED.
int led = 13; //Define LED pin
int buttonpin = 3; //Define the button pin
int val; //Define a numeric variable
void setup()
{
pinMode(led,OUTPUT);
pinMode(buttonpin,INPUT);
}
void loop()
{
span>val = digitalRead(buttonpin); // Check the status of the button
if(val==HIGH) // When the button is pressed, turn on the LED
{
digitalWrite(led,HIGH );
}
else
{
digitalWrite(led,LOW);
}
}
< /blockquote>