I am new to programming with arduino so I am sorry if it is something obvious that I missed.
whenever I try to compile my code I get the error "expected unqualified-id before 'if'", I cannot seem to resolve this issue on my own, maybe someone more experienced can help. This is for a flame sensor module
int sensor = A0;
int sensorValue = 0;
int red = 8; // Multi color LED used to show the state of the flame.
int green = 9;
int blue = 10;
void setup()
{
Serial.begin(9600);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop() {
sensorValue = analogRead(flame);
Serial.println(sensorValue);
}
if(sensorValue > 800) {
digitalWrite(green, HIGH);
}
if(sensorValue < 800) {
digitalWrite(blue, HIGH);
}
if(sensorValue > 400) {
digitalWrite(blue, HIGH);
}
else {
digitalWrite(blue, LOW);
}
if(sensorValue < 400) {
digitalWrite(red, HIGH);
}
delay(50);
}