0
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?

ESP32-S2、bootボタン-スイッチでトグルスイッチ化して遊ぶ。(結果をシリアルポート出力)

0
Last updated at Posted at 2026-08-09

いろいろ注意

過去ログを見よ!!!
esp32 3.3.11

結果

Screenshot From 2026-08-10 05-55-56.png

無題.jpg

プログラム




//ser_toggle1_test1_esp32_s2_1


//インクルド
#include <Arduino.h>


//定義

//定義 変数
int sw = 0;
//int sw = ~0;


//初期化
void setup() {

  //シリアルポートの初期化
  Serial.begin(9600);

  //シリアルポートの接続待ち
  delay(3000);  //決め打ちなので、おかしかったら調整してね!

  //入力の為のボタンスイッチの初期化
  pinMode(0, INPUT_PULLUP);

}  //setup


//メインループ
void loop() {

  //ボタン入力する スイッチの値を反転する
  if (digitalRead(0) == 0) {

    sw = ~sw;                          //反転
    Serial.printf("sw = [%d]\n", sw);  //表示

    delay(300);  //0.3秒待つ

  }  //endif button

  delay(3);  //ダミー

}  //loop



0
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
0
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?