• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeArduinoSensors Kit for ArduinoKY004: Momentary Button Module
Previous Next

KY004: Momentary Button Module

Posted by: admin , April 25, 2014

Use the LED on digital pin 13, and connect the button module input to digital 3, and when button is pressed, the LED will turn on, otherwise, it will turn off.

int Led=13;

int buttonpin=3;

int val;

void setup()

{

pinMode(Led,OUTPUT);

pinMode(buttonpin,INPUT);

}

void loop()

{

val=digitalRead(buttonpin);

if(val==HIGH)

{

digitalWrite(Led,HIGH)

}

else

{

digitalWrite(Led,LOW)

}

}

Tags: Sensors Kit for Arduino

Share!
Tweet

admin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors