This is a easy project which we can complete !
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define samp_siz 4
#define rise_threshold 4
#define sensor_pin A0
int sensorPin = 9;
int sensorValue;
int read_ADC;
int ntu;
// make some custom characters:
byte heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000
};
byte smiley[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b10001,
0b01110,
0b00000
};
byte frownie[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b00000,
0b01110,
0b10001
};
byte armsDown[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};
byte armsUp[8] = {
0b00100,
0b01010,
0b00100,
0b10101,
0b01110,
0b00100,
0b00100,
0b01010
};
void setup(){// put your setup code here, to run once
pinMode(sensor_pin, INPUT);
lcd.begin(20, 4); // Configura lcd numero columnas y filas
lcd.clear();
lcd.setCursor (4,0);
lcd.print("!!Welcome!!");
lcd.setCursor (2,1);
lcd.print(" T.AQI Project");
lcd.setCursor (0,2);
lcd.print(" Made By Thashwanth");
lcd.setCursor (6,3);
lcd.print("Arumugam");
delay(7000);
lcd.clear();
// create a new character
lcd.createChar(0, heart);
// create a new character
lcd.createChar(1, smiley);
// create a new character
lcd.createChar(2, frownie);
// create a new character
lcd.createChar(3, armsDown);
// create a new character
lcd.createChar(4, armsUp);
// set the cursor to the top left
lcd.setCursor(6, 3);
delay(2000);
// Print a message to the lcd.
lcd.print("Welcome!");
lcd.write((byte)1);
delay(2000);
}
void loop(){
read_ADC = analogRead(sensor_pin);
if(read_ADC>208)read_ADC=208;
ntu = map(read_ADC, 0, 208, 300, 0);
lcd.setCursor(0,0);
lcd.print("Turbidity: ");
lcd.print(ntu);
lcd.print(" ");
lcd.setCursor(4,3);
lcd.write((byte)4);
lcd.print("!Welcome!");
lcd.write((byte)1);
lcd.setCursor(0,1);//set cursor (colum by row) indexing from 0
if(ntu<20) lcd.print("Water Very Clean");
if(ntu>=20 && ntu<50) lcd.print("Water Norm Clean");
if(ntu>=50) lcd.print("Water Very Dirty");
delay(2000);
sensorValue = analogRead(A1); // read analog input pin 0
lcd.clear();
lcd.setCursor(0,2);
lcd.print("Air Quality:");
// lcd.setCursor(0,8);
lcd.print(sensorValue);
Serial.print(sensorValue);
if (sensorValue <= 100)
{
lcd.setCursor(15,2);
lcd.print("Good");
}
else if (sensorValue >= 100 && sensorValue < 150){
lcd.setCursor(15,2);
lcd.print("Poor");
}
else {
lcd.setCursor(15,2);
lcd.print("Toxic");
}
}
Comments
Please log in or sign up to comment.