Difference between revisions of "LinkNode 12mm Button Module"

From LinkSprite Playgound
Jump to: navigation, search
(Created page with "== Introduction == This button module hosts momentary push button switch - 12mm Square. It can serve as input for Xduino experiment. ( Press the button output low level ) ...")
 
(No difference)

Latest revision as of 02:27, 13 December 2016

Introduction

This button module hosts momentary push button switch - 12mm Square. It can serve as input for Xduino experiment. ( Press the button output low level )

STM32 A-8.jpg

STM32 A-10.jpg

STM32 A-3.jpg

STM32 A-6.jpg

STM32 A-7.jpg

Wiring & Running

The Button module is connected to the base shield J1:

Button Signal --> LinkNode D1 G0

Open the Arduino IDE serial monitor ( BAUD 9600 ) , you can see the button state .

Button 12mm.png

Button 12mm 2.png

Button 12mm 3.png

Simple Code

const int ButtonPin=0;
int press_count = 0;

void setup() {
  pinMode(ButtonPin, INPUT);
  Serial.begin(9600);        // init serial to 9600b/s
  Serial.println("The Button is connected to the G0 (LinkNode D1)");
}
 
void loop() {
  int sensorValue = digitalRead(ButtonPin);
  if(sensorValue==0)
  {
    delay(10);
    if(sensorValue==0)  // Check if the button is pressed
    {
       press_count++;
       Serial.print("The button is pressed , count:");
       Serial.println(press_count,DEC);
    }
    delay(200);
  }
}