1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

M5NanoC6、GROVER- Button(ボタンスイッチ)で遊ぶ。(スイッチクラス利用)

Last updated at Posted at 2024-10-24

今回のお題

o_coq555.jpg

o_coq556.jpg

結果

o_coq554.jpg

プログラム



//button_Grover_button_M5NanoC6_1

#include <M5NanoC6.h>

#include "Arduino.h"
#include "utility/Button_Class.hpp"

using namespace m5;

Button_Class BtnS;


void setup() {

    NanoC6.begin();

    pinMode(1, INPUT); //Grover GPIO1
  
    pinMode(M5NANO_C6_BLUE_LED_PIN, OUTPUT);
}


void loop() {
    
    uint32_t ms = millis();
    BtnS.setRawState(ms, digitalRead(1)); //Grover GPIO1

    
    if (BtnS.wasPressed()) {
        Serial.println("Button A was pressed");
        digitalWrite(M5NANO_C6_BLUE_LED_PIN, HIGH);
    }
    if (BtnS.wasHold()) {
        Serial.println("Button A was hold");
    }
    if (BtnS.wasReleased()) {
        Serial.println("Button A was released");
        digitalWrite(M5NANO_C6_BLUE_LED_PIN, LOW);
    }
}


1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?