pdf-icon

UNIT Key

SKU:U144

描述

Unit Key 是一款内置RGB灯单按键输入单元,按键轴体采用段落感极强的青轴,键帽可替换,具备出色的机械触感与回弹效果。内嵌一颗SK6812可编程全彩RGB LED,支持256级亮度显示。单元引出两个数字IO接口用于按键状态获取与灯光控制。适于DIY各种需要按键输入交互的应用。

产品特性

  • 青轴(段落感强)
  • SK6812可编程全彩RGB LED

包含

  • 1x Unit Key
  • 1x HY2.0-4P线缆(20cm)

应用

  • 人机交互设计

规格参数

规格 参数
供电电压 DC 5V
按键输出逻辑信号 DC 3.3V
待机电流 DC5V@2mA
工作电流 DC5V@13mA
净重 7.6g
毛重 13.1g
产品尺寸 40 * 24 * 22.6mm
包装尺寸 90 * 135mm

管脚映射

  • UNIT Key
M5CORE - PORT B G36 G26
UNIT Key Btn Input RGB LED Control

原理图

案例程序

Arduino

#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);
}

UIFlow