-38%


















Grove 5-Way Switch 5向開關模組 I2C 通訊
0 out of 5
NT$320 原始價格:NT$320。NT$200目前價格:NT$200。 (未稅)
- 描述
- 評價 (0)
描述
描述
Grove 5-Way Switch 5向開關模組 I2C 通訊
Grove – 5向開關可用於檢測開關位置和事件,如單擊/雙擊/長按等。它可以檢測左/右/上/下/中心5方向。5路開關是多功能控制的絕佳選擇。只需一個小開關即可滿足您對開關控制的所有需求!
功能
- 5 路獨立開關
- 耐熱性好
- 長壽命
- Grove 插座式模組
工作電壓 | 3.3V / 5V |
接口 | I2C |
默認 I2C 地址 | ×03 |
- 遊戲控制
- 多功能控制
硬件概述
引腳圖
Arduino 範例
Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
#include "Grove_Multi_Switch.h" GroveMultiSwitch mswitch[1]; const char* grove_5way_tactile_keys[] = { "KEY A", "KEY B", "KEY C", "KEY D", "KEY E", }; const char* grove_6pos_dip_switch_keys[] = { "POS 1", "POS 2", "POS 3", "POS 4", "POS 5", "POS 6", }; const char** key_names; int deviceDetect(void) { if (!mswitch->begin()) { Serial.println("***** Device probe failed *****"); return -1; } Serial.println("***** Device probe OK *****"); if (PID_VAL(mswitch->getDevID()) == PID_5_WAY_TACTILE_SWITCH) { Serial.println("Grove 5-Way Tactile Switch Inserted!"); key_names = grove_5way_tactile_keys; } else if (PID_VAL(mswitch->getDevID()) == PID_6_POS_DIP_SWITCH) { Serial.println("Grove 6-Position DIP Switch Inserted!"); key_names = grove_6pos_dip_switch_keys; } // enable event detection mswitch->setEventMode(true); // report device model Serial.print("A "); Serial.print(mswitch->getSwitchCount()); Serial.print(" Button/Switch Device "); Serial.println(mswitch->getDevVer()); return 0; } void setup() { Serial.begin(115200); Serial.println("Grove Multi Switch"); // Initial device probe if (deviceDetect() < 0) { Serial.println("Insert Grove 5-Way Tactile"); Serial.println("or Grove 6-Position DIP Switch"); for (;;); } return; } void loop() { GroveMultiSwitch::ButtonEvent_t* evt; delay(1); evt = mswitch->getEvent(); if (!evt) { // dynamic device probe deviceDetect(); delay(1000); return; } if (!(evt->event & GroveMultiSwitch::BTN_EV_HAS_EVENT)) { #if 0 Serial.print("No event, errno = "); Serial.println(mswitch->errno); #endif return; } for (int i = 0; i < mswitch->getSwitchCount(); i++) { Serial.print(key_names[i]); Serial.print(": RAW - "); Serial.print((evt->button[i] & GroveMultiSwitch::BTN_EV_RAW_STATUS)? "HIGH ": "LOW "); if (PID_VAL(mswitch->getDevID()) == PID_5_WAY_TACTILE_SWITCH) { Serial.print((evt->button[i] & GroveMultiSwitch::BTN_EV_RAW_STATUS)? "RELEASED ": "PRESSED "); } else if (PID_VAL(mswitch->getDevID()) == PID_6_POS_DIP_SWITCH) { Serial.print((evt->button[i] & GroveMultiSwitch::BTN_EV_RAW_STATUS)? "OFF ": "ON "); } Serial.println(""); } for (int i = 0; i < mswitch->getSwitchCount(); i++) { if (evt->button[i] & ~GroveMultiSwitch::BTN_EV_RAW_STATUS) { Serial.println(""); Serial.print(key_names[i]); Serial.print(": EVENT - "); } if (evt->button[i] & GroveMultiSwitch::BTN_EV_SINGLE_CLICK) { Serial.print("SINGLE-CLICK "); } if (evt->button[i] & GroveMultiSwitch::BTN_EV_DOUBLE_CLICK) { Serial.print("DOUBLE-CLICK "); } if (evt->button[i] & GroveMultiSwitch::BTN_EV_LONG_PRESS) { Serial.print("LONG-PRESS "); } if (evt->button[i] & GroveMultiSwitch::BTN_EV_LEVEL_CHANGED) { Serial.print("LEVEL-CHANGED "); } } Serial.println(""); } |
資源與文件下載
Grove – 5-Way Switch
The Grove – 5-Way Switch can be used to detect the switch position and event like single click/double click/long press, etc. It can detect left/right/up/down/center 5 directions.
The 5-way switch will be a great option for multifunction control.
With only one small switch to meet all your needs for switch control!
Features
- 5 way switch
- Good heat resistance
- Long operating Life
- Grove compatible
Typical Applications
- Game control
- Multifunction control
評價 (0)
相關商品
-
綠能應用開發模組
1W Solar Panel 80X100 太陽能電池板
0 out of 5NT$147原始價格:NT$147。NT$125目前價格:NT$125。 (未稅)加入購物車產品速覽 -
藍牙模組
Grove – BLE (dual model) HM-13 UART 藍芽模組
0 out of 5NT$837原始價格:NT$837。NT$700目前價格:NT$700。 (未稅)加入購物車產品速覽 -
WIFI 模組
Grove – Uart Wifi ESP8266 串口 WIFI 通訊模組
0 out of 5NT$517原始價格:NT$517。NT$425目前價格:NT$425。 (未稅)加入購物車產品速覽 -
紅外線科技
Grove – Line Finder v1.1 循線模組
0 out of 5NT$145原始價格:NT$145。NT$135目前價格:NT$135。 (未稅)加入購物車產品速覽
商品評價
目前沒有評價。