Devices & Components
Arduino Uno Rev3
Breadboard (generic)
Button Module
Resistor 1k ohm
5 mm LED: Red
Jumper wires (generic)
Software & Tools
Arduino IDE
Project description
Code
KY-004_Button_Module
c_cpp
1//**********************************************************************************************************// 2// Author: 3// WellTronic 4// 5// Description: 6// This code is part of a video series covering all Arduino sensors from the Arduino sensor kit. 7// One of the sensors in this video series is the button module sensor. 8// 9// In this video I will explain step by step how to use the button module 10// https://www.youtube.com/watch?v=ZdAWmokaiNk 11// 12// You're also welcome to take a look at the YouTube channel for more details about hardware and software. 13// https://www.youtube.com/channel/UC0UCNqE8i4unG8nfuakd0vw 14// 15// Enjoy working with this sensor and see you soon :) ! 16// 17//**********************************************************************************************************// 18 19 20int buttonPin = 4; 21int ledPin = 3; 22 23bool buttonState = false; 24 25void setup() { 26pinMode(buttonPin,INPUT); 27pinMode(ledPin,OUTPUT); 28 29} 30void loop() { 31 32buttonState = digitalRead(buttonPin); 33 34 if ( buttonState == true){ 35 digitalWrite(ledPin, HIGH); 36 } 37else { 38 digitalWrite(ledPin, LOW); 39} 40 41 42} 43
KY-004_Button_Module
c_cpp
1//**********************************************************************************************************// 2// Author: 3// WellTronic 4// 5// Description: 6// This code is part of a video series covering all Arduino sensors from the Arduino sensor kit. 7// One of the sensors in this video series is the button module sensor. 8// 9// In this video I will explain step by step how to use the button module 10// https://www.youtube.com/watch?v=ZdAWmokaiNk 11// 12// You're also welcome to take a look at the YouTube channel for more details about hardware and software. 13// https://www.youtube.com/channel/UC0UCNqE8i4unG8nfuakd0vw 14// 15// Enjoy working with this sensor and see you soon :) ! 16// 17//**********************************************************************************************************// 18 19 20int buttonPin = 4; 21int ledPin = 3; 22 23bool buttonState = false; 24 25void setup() { 26pinMode(buttonPin,INPUT); 27pinMode(ledPin,OUTPUT); 28 29} 30void loop() { 31 32buttonState = digitalRead(buttonPin); 33 34 if ( buttonState == true){ 35 digitalWrite(ledPin, HIGH); 36 } 37else { 38 digitalWrite(ledPin, LOW); 39} 40 41 42} 43
Downloadable files
Schematics
Schematics
Comments
Only logged in users can leave comments