fork download
  1. #include <Servo.h>
  2.  
  3. Servo servo;//サーボのインスタンス
  4. byte val=0;
  5.  
  6. void setup() {
  7. Serial.begin(9600);
  8. servo.attach(3);
  9. }
  10.  
  11.  
  12. void loop(){
  13. if(Serial.available() > 0){
  14.  
  15. val = Serial.read();
  16. Serial.print(val);
  17.  
  18. if(val == '1'){ servo.write(90);delay(1000); }
  19. else{ servo.write(0); delay(1000);}
  20.  
  21.  
  22. }
  23.  
  24. }
Runtime error #stdin #stdout 0.01s 4672KB
stdin
Standard input is empty
stdout
Standard output is empty