#include <Servo.h>
Servo myservo;
int pos = 0; int port = A0; int valeur = 0; float vin = 0; float imax = 0; int deg = 0; int n = 0;
void setup() { Serial.begin(9600); myservo.attach(9); }
void loop()
{
for(pos = 0; pos <= 190; pos += 1) { myservo.write(pos); valeur = analogRead(port); vin = (valeur * 5.0) / 1024.0; n = n + 1 ; if (vin > imax) { (imax = vin); (deg = n); } delay(50); } Serial.print(deg); (imax = 0); (deg = 0); (n = 0);
}