#include <Servo.h>
Servo servo;//サーボのインスタンス
byte val=0;
void setup() {
Serial.begin(9600);
servo.attach(3);
}
void loop(){
if(Serial.available() > 0){
val = Serial.read();
Serial.print(val);
if(val == '1'){ servo.write(90);delay(1000); }
else{ servo.write(0); delay(1000);}
}
}
I2luY2x1ZGUgPFNlcnZvLmg+CgpTZXJ2byBzZXJ2bzsvL+OCteODvOODnOOBruOCpOODs+OCueOCv+ODs+OCuQpieXRlIHZhbD0wOwoKdm9pZCBzZXR1cCgpIHsKU2VyaWFsLmJlZ2luKDk2MDApOwogIHNlcnZvLmF0dGFjaCgzKTsKfQoKCnZvaWQgbG9vcCgpewogIGlmKFNlcmlhbC5hdmFpbGFibGUoKSA+IDApewogICAgCiAgICB2YWwgPSBTZXJpYWwucmVhZCgpOwogICAgU2VyaWFsLnByaW50KHZhbCk7CiAgICAKICAgICAgaWYodmFsID09ICcxJyl7ICBzZXJ2by53cml0ZSg5MCk7ZGVsYXkoMTAwMCk7IH0KICAgICAgZWxzZXsgc2Vydm8ud3JpdGUoMCk7IGRlbGF5KDEwMDApO30KCgogICB9Cgp9