Skip to content

Instantly share code, notes, and snippets.

@hm0429
Created October 16, 2015 14:08
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 hm0429/40b5c716c2a72649eac5 to your computer and use it in GitHub Desktop.
Save hm0429/40b5c716c2a72649eac5 to your computer and use it in GitHub Desktop.
Arduino_Button
#define LED_PIN 13
#define BUTTON_PIN 7
void setup() {
// LED_PIN (PIN 13) を OUTPUT として設定します
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
}
void loop() {
// ボタンが押されているかどうかの値(HIGH/LOW)を取得します
bool isButtonPushed = digitalRead(BUTTON_PIN);
if (isButtonPushed) {
digitalWrite(LED_PIN, HIGH); // LED_PIN を HIGH にします(点灯)
} else {
digitalWrite(LED_PIN, LOW); // LED_PIN を LOW にします(消灯)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment