pdf-icon

Arduino Quick Start

2. Devices & Examples

6. Applications

Chain DualKey Switch

APIs and example programs related to the Chain DualKey Switch.

Example Program

Build Requirements

  • M5Stack Board Manager version ≥ 3.2.4
  • Board option = M5ChainDualKey
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#define SWITCH_BLE 8 #define SWITCH_WIFI 7 void setup() { pinMode(SWITCH_BLE, INPUT); pinMode(SWITCH_WIFI, INPUT); Serial.begin(115200); } void loop() { if (digitalRead(SWITCH_BLE) == HIGH) { Serial.println("Switch in BLE position"); } else if (digitalRead(SWITCH_WIFI) == HIGH) { Serial.println("Switch in WIFI position"); } else { Serial.println("Switch in middle position"); } delay(500); }

This program checks the switch position every 500 milliseconds and prints the current state message to the Serial Monitor:

On This Page