Hello Cmmunity,
This is my first post cause I can't find solution to my problem !
Some syntax problem with the if cause Arduino say me :
expected unqualified-id before numeric constant
This is my code :
const int pingPin = 7;
const int WaterPin=7;//Pour détecter l'eau
const int pompe=12;//Pour controller la pompe
void setup() {
Serial.begin(9600);
pinMode(pompe,OUTPUT);
}
void loop()
{
long duration, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
cm = microsecondsToCentimeters(duration);
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}
if (cm <= 5) {
// On allume la pompe
digitalWrite(pompe, HIGH);
} else if (cm >= 15) {
// On éteint la pompe
digitalWrite(pompe, LOW);
} else {
digitalWrite(pompe, LOW);
}
Thanks a lot !
Raphael.