Asterisk+Arduino
スケッチ
#include <Servo.h> Servo servo1; int servoPin = 10; int up = 60; int down = 15; void setup(){ servo1.attach(servoPin); servo1.write(down); Serial.begin(9600); Serial.print("OK"); } void servo_loop(char ch) { int i; servo1.write(down); for(i=0;i<(int)(ch -'0');i++){ servo1.write(up); delay(150); servo1.write(down); delay(200); } } void loop(){ if(Serial.available()) { char ch = Serial.read(); switch(ch) { case '1'...'9': servo_loop(ch); break; case 'd': servo1.write(down); break; case 'u': servo1.write(up); break; case 's': servo1.write(down); servo1.write(up); delay(150); servo1.write(down); break; } } }