SKU:U144
Unit Key is a single mechanical key input
unit with built-in RGB LED. The key shaft adopts Blue switch
with tactile bump and audible click features. Embedded with one programable RGB LED - SK6812, supports 256 level brightness. Two digital IOs are available for key status and LED control key status and lighting control. Suitable for multiple HMI applications.
Specification | Parameters |
---|---|
Power Supply | DC 5V |
Output Logical Signal | DC 3.3V |
Standby Current | DC5V@2mA |
Operating current | DC5V@13mA |
Net weight | 7.6g |
Gross weight | 13.1g |
Product Dimensions | 40 * 24 * 22.6mm |
Package Size | 90 * 135mm |
M5CORE - PORT B | G36 | G26 |
---|---|---|
UNIT Key | Btn Input | RGB LED Control |
#include <FastLED.h>
#include <M5Stack.h>
uint8_t ledColor = 0;
#define KEY_PIN 36
#define LED_PIN 26
CRGB LED[1];
void setup() {
M5.begin();
M5.Lcd.setTextSize(3);
M5.Lcd.print("\n UNIT-KEY Example\n\n Key State:");
/* Init key pin */
pinMode(KEY_PIN, INPUT_PULLUP);
/* Init RGB led */
FastLED.addLeds<SK6812, LED_PIN, GRB>(LED, 1);
LED[0] = CRGB::Blue;
FastLED.setBrightness(0);
}
void loop() {
/* If Key was pressed */
if (!digitalRead(KEY_PIN)) {
M5.Lcd.setCursor(75, 130);
M5.Lcd.print((" Pressed "));
FastLED.setBrightness(255);
FastLED.show();
/* Hold until the key released */
while (!digitalRead(KEY_PIN))
;
} else {
M5.Lcd.setCursor(75, 130);
M5.Lcd.println(("Released"));
FastLED.setBrightness(0);
FastLED.show();
}
delay(100);
}