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: スイッチの状態を確認する

Posted at

プログラム

gpio01.ino
// ---------------------------------------------------------------------
/*
	gpio01.ino
						Feb/28/2025
*/
// ---------------------------------------------------------------------
#define	PROGRAM	"gpio01.ino"
#define	VERSION	"2025-02-28 PM 16:59"

uint8_t gpio_pin1 = 32;
uint8_t gpio_pin2 = 33;

// ---------------------------------------------------------------------
void setup()
{
	Serial.begin(115200);

	pinMode(gpio_pin1, INPUT);
	pinMode(gpio_pin2, INPUT);

	delay(1000);
	Serial.println(PROGRAM);
	Serial.println(VERSION);
}

// ---------------------------------------------------------------------
void loop()
{
	if(digitalRead(gpio_pin1) == LOW)
		{
		Serial.println("*** LOW pin1 ***");
		}
	else
		{
		Serial.println("*** HIGH pin1 ***");
		}

	delay(500);

	if(digitalRead(gpio_pin2) == LOW)
		{
		Serial.println("*** LOW pin2 ***");
		}
	else
		{
		Serial.println("*** HIGH pin2 ***");
		}

	delay(500);
}

// ---------------------------------------------------------------------

実行時の様子

Arduino IDE 2.3.4 を使いました
image.png

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?