Skip to content

Instantly share code, notes, and snippets.

@likersacademia
Last active August 16, 2018 04:15
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/518e31c53b1a0690327e50c0dfe5e180 to your computer and use it in GitHub Desktop.
Save likersacademia/518e31c53b1a0690327e50c0dfe5e180 to your computer and use it in GitHub Desktop.
//* スイッチのON-OFFをシリアルモニターに表示するプログラム
#define buttonPin 12
int buttonState = 0;
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.println("Switch ON"); //Switch ONのところを好きな文章にできます
delay(1000); //判定間隔(1000=1秒)が変わります。
} else {
Serial.println("Switch OFF"); ////Switch OFFのところを好きな文章にできます
delay(1000); //判定間隔(1000=1秒)が変わります。
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment