const int AOUTpin=0;//the AOUT pin of the CO sensor goes into analog pin A0 of the arduino
const int RPin = 11; // RED LED
const int GPin = 12; // GREEN LED
const int BPin = 13; // BLUE LED
int monitoringValue = 0;
void setup()
{
Serial.begin(115200);//sets the baud rate
pinMode(Rpin, OUTPUT);
pinMode(Bpin, OUTPUT);
pinMode(Gpin, OUTPUT);
}
void loop()
{
monitoringValue = analogRead(AOUTpin);//reads the analaog value from the CO sensor's AOUT pin
if (monitoringValue >= 150) //sensor for CO2 value higher than unhealthy range
{
digitalWrite(Rpin, HIGH); //Red led indicator for danger
digitalWrite(Bpin, LOW);
digitalWrite(Gpin, LOW);
}
else if ((monitoringValue >= 51) && (monitoringValue <= 149)) //moderate unhealthy CO2 value blue indicator
{
digitalWrite(Rpin, LOW);
digitalWrite(Bpin, HIGH);// Blue led indicator for unhealthy
digitalWrite(Gpin, LOW);
}
else //less than 51 good air quality
{
digitalWrite(Rpin, LOW);
digitalWrite(Bpin, LOW);
digitalWrite(Gpin, HIGH);// Green led indicator for good
}
Serial.print("CO value: ");
Serial.println(monitoringValue);//prints the CO value
Serial.print(" PPM");
Serial.println();
delay(1000); //time measured in milliseconds 1000 = 1 second
}
//Hi i need help i seem to be having an error message of Rpin not declared in this scope even though I have defined it as a global variable.