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?

More than 1 year has passed since last update.

ESP32: GPIO 入力

Posted at

image.png

プログラム

button_monitor.ino
// ---------------------------------------------------------------------
//	button_monitor.ino
//
//						Feb/04/2023
// ---------------------------------------------------------------------
#define	PROGRAM	"button_monitor.ino"
#define	VERSION	"2023-2-4 AM 10:30"

const int buttonPin = 15;  // the number of the pushbutton pin
const int ledPin = 13;    // the number of the LED pin

// variables will change:
int buttonState = 0;
int buttonState_before = 0;

// ---------------------------------------------------------------------
void setup()
{
	Serial.begin(115200);
	delay(3000);
	Serial.println(PROGRAM);
	Serial.println(VERSION);
	Serial.println();

	pinMode(ledPin, OUTPUT);
	pinMode(buttonPin, INPUT);
}

// ---------------------------------------------------------------------
void loop() {
	buttonState = digitalRead(buttonPin);

	if (buttonState == HIGH) {
		digitalWrite(ledPin, HIGH);
	} else {
		digitalWrite(ledPin, LOW);
	}

	if (buttonState_before != buttonState)
		{
		Serial.println(buttonState);
		Serial.println(PROGRAM);
		Serial.println(VERSION);
		Serial.println();

		buttonState_before = buttonState;
		}
}

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