Programmation d'une carte arduino avec servomotor + light sensor

Bonjour à tous,
En ce moment j'ai un réel problème. Pour mon projet de bac je dois faire tourner un servomoteur en fonction de l'intensité de la lumière. Donc j'ai une carte arduino UNO avec un motor shield aisnis qu'un light sensor et un petit serov moteur.
L'échéance étant la semaine prochaine, mon programme ne fonctionne toujours pas :cry:
J'aurai vraiment besoin d'aide s'il vous plait

voici le code que j'ai réalisé pour l'instant, seulement plein de messages d'erreurs s'affichent par la suite :

#include <Servo.h>
volatile int pos = 0
volatile int photocellPin = 0;
volatile int photocellReading;

void setup(void)
{
Servo Myservo ;

Serial.begin(9600);
Myservo.attach(8) ;
}

void loop(void)
{
photocell Reading = analogRead(photocellPin);

Serial.print(“Analog reading = ”);
Serial.print(photocellReading);

if (photocellReading < 10)
{
Serial.print(“ - Noir”);
Pos = 18 ;
Myservo.write(pos) ;
delay(25) ;
}
else if (photocellReading < 200)
{
Serial.print(“ - Tamisée”);
Pos = 54 ;
Myservo.write(pos) ;
delay(35) ;

}
else if (photocellReading < 500)
{
Serial.print(“ - Moyenne”);
Pos = 90 ;
Myservo.write(pos) ;
delay(45) ;

}
else if (photocellReading < 800)
{
Serial.print(“ - Lumineux”);
Pos = 126 ;
Myservo.write(pos) ;
delay(55) ;

}
else
{
Serial.print(“ – Très lumineux”);
Pos = 162 ;
Myservo.write(pos) ;
delay(65) ;

}

delay(1000);
}

Le message d'erreur principal étant : 'Moyenne' was not declared in this scope et plein d'autre non déclaré également

Bonjour,

Mets ton code entre balises.

Il te suffit de corriger les erreurs en commençant par la première. Les messages d'erreur sont très explicites.

Pourquoi tu as déclaré tes variables (et même tes constantes) comme volatiles. C'est complètement inutile.

Donc après avoir corrigé le code j’obtiens ceci, es ce que ça semble juste?

#include <Servo.h>

void setup(void)
{
Serial.begin(9600);

}

void loop(void)
{
Servo Myservo = Servo();
Myservo.attach(8) ;
int Pos = 0;
int photocellPin = 0;
int photocellReading;

photocellReading = analogRead(photocellPin);

Serial.print("Analog reading = ");
Serial.print(photocellReading);

if (photocellReading < 10)
{
Serial.print(" - Noir");
Pos = 18 ;
Myservo.write(Pos) ;
delay(25) ;
}
else if (photocellReading < 200)
{
Serial.print(" - Tamisée");
Pos = 54 ;
Myservo.write(Pos) ;
delay(35) ;

}
else if (photocellReading < 500)
{
Serial.print(" - Moyenne");
Pos = 90 ;
Myservo.write(Pos) ;
delay(45) ;

}
else if (photocellReading < 800)
{
Serial.print(" - Lumineux");
Pos = 126 ;
Myservo.write(Pos) ;
delay(55) ;

}
else
{
Serial.print(" – Très lumineux");
Pos = 162 ;
Myservo.write(Pos) ;
delay(65) ;

}

delay(1000);
}

kamill:
Bonjour,

Mets ton code entre balises.