#define sensor A0
const int r = 11;
const int g =10;
const int b= 9;
int gasLevel = 0;
String quality ="";
void setup() {
Serial.begin(9600);
pinMode(sensor,INPUT);
pinMode(r, OUTPUT) ;
pinMode( g, OUTPUT);
pinMode (b, OUTPUT);
}
void setColor(int red, int green, int blue) {
analogWrite(r, red );
analogWrite(g, green );
analogWrite(b, blue );
}
void loop()
{
gasLevel = analogRead(sensor);
if(gasLevel<91){
quality = " Perfect!";
setColor(0,0,127);
}
else if (gasLevel >91 && gasLevel<115){
quality = " Poor!";
setColor(0,46,63);
}
else if (gasLevel >115 && gasLevel<130){
quality = "Very bad!";
setColor(0,127,0);
}
else if (gasLevel >130 && gasLevel<150){
quality = "see ya!";
setColor(127,30,0);
}
else if ( gasLevel >150 && gasLevel< 175 0){
quality = " Eating nuclear waste is better";
setColor(127,13,0);
}
else if (gasLevel<200 ) {
quality = "Nice knowing you";
setColor(127,0,0);
}
Serial.println("Air Quality:");
Serial.println(quality);
Serial.println(analogRead(0));
delay(2000);
}
Comments