Im new to Arduino, haven't really learn much about it but my college final year's project is coming and you are very unlucky to be in a shit college that the lecturer did not teach you anything about Arduino but expect you to include Arduino in your project. So here's my coding...and I do not know what is wrong. Please do list out all my mistake for me thanks.
int irmotionPin = 4; // Pin of IR Motion Sensor
int relayPin = 8; // Pin of Relay Module
void setup(){
Serial.begin(9600);
pinMode(relayPin, OUTPUT); // Set Pin connected to Relay as an OUTPUT
digitalWrite(relayPin, LOW); // Set Pin to LOW to turn Relay OFF
}
void loop(){
while (digitalRead(irmotionPin) == HIGH); // If Motion detected
digitalWrite(relayPin, HIGH); // Turn Relay ON
Serial.println("Relay is OFF");
delay(500);
}
digitalWrite(relayPin, LOW); // Turn Relay OFF
Serial.println("Relay is OFF");
delay(500);
}
and my error message is this :
Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"
Sketch_project_1_lvl_3:18: error: expected constructor, destructor, or type conversion before '(' token
digitalWrite(relayPin, LOW); // Turn Relay OFF
^
Sketch_project_1_lvl_3:19: error: 'Serial' does not name a type
Serial.println("Relay is OFF");
^
Sketch_project_1_lvl_3:20: error: expected constructor, destructor, or type conversion before '(' token
delay(500);
^
Sketch_project_1_lvl_3:21: error: expected declaration before '}' token
}
^
exit status 1
expected constructor, destructor, or type conversion before '(' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Thanks..