Bonjour, j'ai un soucis avec mon programme,
Je souhaite utiliser un servomoteur avec une photorésistance.
Quand il fait obscure le servo est à 180°
Quand il fait plein jour le servo est à 0°
Avec la prog "sweep" le servo marche nickel
Avec un autre servo(tower pro micro servo 9g SG90) mon programme agit correctement sur le servo.
#include <Servo.h>
Servo myservo;
int pos = 0;
const int pResistor = A0; // Photoresistor at Arduino analog pin A0
int value; // Store value from photoresistor (0-1023)
void setup(){
Serial.begin(9600);
myservo.attach(9);
pinMode(pResistor, INPUT);// Set pResistor - A0 pin as an input (optional)
}
void loop(){
value = analogRead(pResistor);
Serial.print("Luminostité:");
Serial.println(value);
if (value <= 450){
myservo.write(180);
}
else{
myservo.write(0);
}
delay(500); //Small delay
Serial.print("Angle:");
Serial.println(myservo.read());
}