'2) Sensor/Button'에 해당되는 글 2건

  1. 2016.09.12 Button Switch Module [S062]
  2. 2016.09.12 Key Switch Module (KY-004) [S024]

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' 카테고리의 다른 글

Button Switch Module [S062]  (0) 2016.09.12
Key Switch Module (KY-004) [S024]  (0) 2016.09.12
Posted by RD IoT RDIoT

댓글을 달아 주세요

Key Switch Module (KY-004) [S024] 



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


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


* Specs

The Keyes KY-004 Key Switch Module is a simple on/off Micro switch compatible with Arduino systems.   

Material: FR4

Length: 25mm

Width: 16mm

Height: 10mm

Weight: 1.5g

Operating Voltage: 5v DC


* Contents

- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>


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

int R = 2;

byte lastButton = HIGH;

byte nowButton = HIGH;


void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");

  pinMode(R, INPUT);

  digitalWrite(R, HIGH);


  delay(1000);


  lcd.clear();

}


void loop()

{

 

  lcd.setCursor(0,0);

  lcd.print("S024:KY-004KeySwitch");


  byte nowButton = digitalRead(R);


  lcd.setCursor(0,1);

  lcd.print("value="+(String)nowButton);


  if (HIGH == lastButton)

  {

    if (LOW == nowButton)

    {

     lcd.setCursor(0,2);

     lcd.print("pushed  ");

    }

  }

  else

  {

    if (HIGH == nowButton)

    {

     lcd.setCursor(0,2);

     lcd.print("released");

    }

  }

 

 lastButton = digitalRead(R);

 delay(100);


}

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

Button Switch Module [S062]  (0) 2016.09.12
Key Switch Module (KY-004) [S024]  (0) 2016.09.12
Posted by RD IoT RDIoT

댓글을 달아 주세요