WellTronic
Published © GPL3+

KY-004 Button Module

Here you will find the code to start up with the Button Module. Have Fun !

BeginnerFull instructions provided3,268
KY-004 Button Module

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×1
Button Module
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
5 mm LED: Red
5 mm LED: Red
×1
Resistor 1k ohm
Resistor 1k ohm
×1

Hand tools and fabrication machines

Arduino IDE

Story

Read more

Schematics

Schematics

Code

KY-004_Button_Module

C/C++
//**********************************************************************************************************//
// Author: 
// WellTronic
//
// Description:
// This code is part of a video series covering all Arduino sensors from the Arduino sensor kit.
// One of the sensors in this video series is the button module sensor.
//
// In this video I will explain step by step how to use the button module 
// https://www.youtube.com/watch?v=ZdAWmokaiNk
//
// You're also welcome to take a look at the YouTube channel for more details about hardware and software.
// https://www.youtube.com/channel/UC0UCNqE8i4unG8nfuakd0vw
// 
// Enjoy working with this sensor and see you soon :) !
//
//**********************************************************************************************************//


int buttonPin = 4;
int ledPin = 3;

bool buttonState = false;

void setup() {
pinMode(buttonPin,INPUT);
pinMode(ledPin,OUTPUT);

}
void loop() {
  
buttonState = digitalRead(buttonPin);

 if ( buttonState == true){
  digitalWrite(ledPin, HIGH);
 }
else {
  digitalWrite(ledPin, LOW);
}


}

Credits

WellTronic
5 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.