
Arduino Quick Start
Air Quality button input related APIs and example program.
#include <M5Unified.h>
void setup() {
  
  auto cfg = M5.config(); 
  cfg.serial_baudrate = 115200;
  M5.begin(cfg);
  M5.Lcd.clear();
  M5.Lcd.setTextSize(2);
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.println("M5AirQ Button Test");
}
void loop() {
  M5.update();           
  // Detect BtnA (GPIO0) click
  if (M5.BtnA.wasClicked()) {
    Serial.println("AirQ BtnA clicked");
    M5.Lcd.println("BtnA clicked");
  }
  // Detect BtnB (GPIO8) click
  if (M5.BtnB.wasClicked()) {
    Serial.println("AirQ BtnB clicked");
    M5.Lcd.println("BtnB clicked");
  }
  delay(10);
}After uploading, press the buttons to see the following effect:
 
 The button functionality uses the Button_Class from the M5Unified library. For more button-related APIs, please refer to the documentation below: