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?

M5Stamp S3でボタン入力して遊ぶ

Last updated at Posted at 2024-09-03

M5Stamp S3でボタン入力して遊ぶ

目的
GPIOのテスト
(いきなり、ドラクエ1でいうところのレベル1)

結果

o_coq364.jpg

o_coq365.jpg

プログラム



//WS2812_button_S3_1


//初期化
void setup() {

  //GPIOの初期化
  pinMode(21, OUTPUT); //WS2812
  pinMode(15, INPUT); //button

}//setup


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

  //ボタンの信号の読み込み
  int a = digitalRead(15);


  //ボタンが押されたら点灯、ボタンが離れたら消灯
  if ( a != 0 ) {

    //白を点灯
    neopixelWrite(21, 64, 64, 64);

  } else {

    //消灯
    neopixelWrite(21, 0, 0, 0);

  }//endif


  delay(300);//0.3秒待つ

}//loop


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?