Dream Saver

13:18 PM 07 Jul, 2018
  • 0
  • 0
  • 0

This project is a pillow that senses the amount of moisture present in a pillow. This is very useful because excessive over night sweating is one of the early symptoms of cancer .

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
 

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
const int read = A0; //Sensor AO pin to Arduino pin A0
int value; 
int  waterValue;
const int BUZ11 = 11; 
 
void setup() {
  lcd.init(); 
  lcd.backlight(); 
  lcd.setCursor(0,0); 
  lcd.print(" Water Sensor ");
}
 
void loop() {
  value = analogRead(read); //Read data from analog pin and store it to value variable
  waterValue= value*100/1024;
  lcd.setCursor(6,1); //place cursor at 6 column,2 row
  lcd.print(waterValue); //value displayed on lcd 
  delay(200); //delay 200ms 
  lcd.setCursor(9,1); //place cursor at 9 column,2 row
  lcd.print('%'); //value displayed on lcd 
  delay(10000); //delay 10 s
  if ( waterValue > 75 ){
     tone(BUZ11,262,500);
        delay(500);
    }
    
  lcd.clear(); //Clean the screen
  delay(1000);
  
}