Skip to content

Instantly share code, notes, and snippets.

@likersacademia
Last active April 2, 2019 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save likersacademia/e502f3a22ef75dad196417758691ed16 to your computer and use it in GitHub Desktop.
Save likersacademia/e502f3a22ef75dad196417758691ed16 to your computer and use it in GitHub Desktop.
// スイッチが押されたときにLEDを点滅させるプログラム
#define buttonPin 19 //INA:19 INB:14
#define ledPin 5 //OUTA:5 OUTB:10
bool buttonState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
} else {
digitalWrite(ledPin, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment