Button Switch Module [S062] 



https://www.youtube.com/watch?v=s31LVVFs71E


*GitHubhttps://github.com/rdiot/rdiot-s062.git



* Specs

Weight:10 g

Color: as picture show

Size:35mmx23mmx1mm/1.38"x0.91"x0.04"(inch) (approx)

What is an electronic brick? An electronic brick is an electronic module which can be assembled like Lego bricks simply by plugging in and pulling out. Compared to traditional universal boards and circuit modules assembled with various electronic components, electronic brick has standardized interfaces, plug and play, simplifying construction of prototype circuit on one's own. There are many types of electronic bricks, and we provide more than twenty types with different functions including buttons, sensors, Bluetooth modules, etc, whose functions cover from sensor to motor drive, from Ethernet to wireless communication via Bluetooth, and so on. We will continue to add more types to meet the various needs of different projects.

Electronic brick of button switch is finger-sized, which can be connected to I/O port of main board or externally disconnected to check the switch state so as to control ON/OFF of LED lamp.

Features:

1. Plug and play, easy to use. Compatible with the mainstream 2.54 interfaces and 4-Pin Grove interfaces in the market.

2. With use of M4 standard fixed holes, compatible with M4-standard kits such as Lego and Makeblock

3. Hardware with debouncing function for more stable output


* Contents

- Connect

G ----- GND

V ----- 5V

S ----- D2


- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

 

LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004

 

int button=2; //connect button to D2

 

void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");

 

  delay(1000);

 

  lcd.clear();

}

 

void loop()

{

 

  lcd.setCursor(0,0);

  lcd.print("S062:Button Module");

 

  lcd.setCursor(0,1);

  lcd.print("btn_read=" + (String)digitalRead(button) + "  ");

 

 

  lcd.setCursor(0,2);

  if(digitalRead(button)==HIGH) 

  {

     lcd.print("STAT = OFF ");

  }

  else if(digitalRead(button)==LOW) 

  {

     lcd.print("STAT = ON ");

  }

 

}

'2) Sensor > Button' 카테고리의 다른 글

Key Switch Module (KY-004) [S024]  (0) 2016.09.12
Posted by RDIoT
|