Moin, ich muss für die schule einen Gießalarm programmieren, allerdings habe ich nun das Problem das ich nicht weiter in der Programmierung komme und ich diese fehlermeldungen einfach nicht verstehe. Bitte, bitte helft mir. verwendete Bauteile sind arduino nano, passive Buzzer 5V, PIR-Sensor-HC-SR501, capacitive soil moisture sensor v2.0 und ein Breadboard.
```cpp
const int dry = 655; //wert für trockenen Sensor
const int wet = 318; //wert für nassen Sensor
#define pirPin 2
#define buzzerPin 5
int val = 0; //create variables melder
bool motionState = false; //We start with no motion detected
void alarm (int 500, int 1000);
void setup()
{
// configure the pins as input or output
pinMode (buzzerPin, OUTPUT);
pinMode (pirPin, INPUT);
Serial.begin(9600);
}
void loop()
{
int sensorVal = analogRead(A0);
// Sensor has a range of 318 to 655
// we want to translate this to a scale or 0% to 100%
int percentageHumidity = map(sensorVal, wet, dry, 100, 0);
Serial.print(percentageHumidity);
Serial.println("%");
delay(100);
// read out the pirPin and store as val
val = digitalRead(pirPin);
// if motion is detected (pirPin = HIGH), do the following:
if (percentageHumidity > 40 && motionState == HIGH){
alarm(500, 1000);
delay(150);
// Change the motion state to true (motion detected):
(motionState == true)
Serial.println ("bewegung + schlechter wert");
}
else{ Serial.print ("keine bewegung oder wert ok");
delay(500);
}
delay(500);
}
***fehlermeldungen:***
C:\Users\Notebook\AppData\Local\Temp\2ac78234-7137-468e-9454-35bd3510ed7f_Gießalarm.zip.d7f\Gießalarm\alarm3\alarm3.ino:8:17: error: expected ',' or '...' before numeric constant
C:\Users\Notebook\AppData\Local\Temp\2ac78234-7137-468e-9454-35bd3510ed7f_Gießalarm.zip.d7f\Gießalarm\alarm3\alarm3.ino: In function 'void loop()':
C:\Users\Notebook\AppData\Local\Temp\2ac78234-7137-468e-9454-35bd3510ed7f_Gießalarm.zip.d7f\Gießalarm\alarm3\alarm3.ino:34:19: error: too many arguments to function 'void alarm(int)'
C:\Users\Notebook\AppData\Local\Temp\2ac78234-7137-468e-9454-35bd3510ed7f_Gießalarm.zip.d7f\Gießalarm\alarm3\alarm3.ino:8:6: note: declared here
C:\Users\Notebook\AppData\Local\Temp\2ac78234-7137-468e-9454-35bd3510ed7f_Gießalarm.zip.d7f\Gießalarm\alarm3\alarm3.ino:38:4: error: expected ';' before 'Serial'
exit status 1
Compilation error: expected ',' or '...' before numeric constant