Étape 1: Connexions et Code
#include < Servo.h >
octet com = 0 ;
Servo myServo ;
void setup() {Serial.begin(9600) ;
myServo.attach(9) ;
Delay(2000) ;
Serial.Write(0xAA) ;
Serial.Write(0x37) ;
Delay(1000) ;
Serial.Write(0xAA) ;
Serial.Write(0x21) ; }
void loop() {}
{while(Serial.available())}
com = Serial.read() ;
{Switch(com)}
0 x 11-affaire : //command 1
myServo.write(0) ;
rupture ;
0 x 12-affaire : //command 2
myServo.write(45) ;
rupture ;
0 x 13 de cas : //command 3
myServo.write(90) ;
rupture ;
arrêt 0 x 14 : //command 4 myServo.write(135) ;
rupture ;
0 x 15-affaire : //command 5 myServo.write(180) ;
rupture ;
}
}
}