Beruflich Dokumente
Kultur Dokumente
*/
#include <LiquidCrystal.h>
#include <Key.h>
#include <Keypad.h>
#include <SoftwareSerial.h>
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {10, 9, 8, 7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 5, 4}; //connect to the column pinouts of the keypad
LiquidCrystal lcd(A0,A1,A2,A3,A4,A5 );
int X;
int Y;
float TIME = 0;
float FREQUENCY = 0;
float WATER = 0;
float TOTAL = 0;
float LS = 0;
void setup()
lcd.setCursor(0,1);
delay(4000);
lcd.clear();
digitalWrite(in_1,HIGH);
void loop()
if ( customKey && ( keycount <4) && ( customKey !='*') && ( customKey !='#')){
keycount ++;
if(( code [0]=='1') && ( code [1]=='2') && ( code [2]=='3') && ( code [3]=='4'))
openValve();
delay(2000);
waterFlow();
if( customKey == '#') //Cancel/Lock Key is pressed clear display and lock
{
Lock (); //Lock and clear display
SendMessage();
pswd();
//===================================================================================
==========
//===================================================================================
==========
void pswd(){
lcd.clear();
lcd.print("ENTER PSWD:");
keycount =0;
//===================================================================================
=========
//function for closing the gate valve to stop water from flowing
//===================================================================================
===========
void Lock ()
{ digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,LOW) ;
delay(1000);
//===================================================================================
============
//===================================================================================
=============
void openValve(){
lcd.clear();
lcd.setCursor(0,0);
digitalWrite(in_1,LOW) ;
digitalWrite(in_2,HIGH) ;
delay(1000);
//===================================================================================
================
//===================================================================================
=================
void waterFlow(){
int count;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("VOL. :0.00");
lcd.setCursor(0,1);
lcd.print("TOTAL:");
lcd.print( TOTAL);
lcd.print("L");
//delay (3000);
X = pulseIn(input, HIGH);
Y = pulseIn(input, LOW);
TIME = X + Y;
FREQUENCY = 1000000/TIME;
WATER = FREQUENCY/12;
LS = WATER;
if(FREQUENCY >= 0)
if(isinf(FREQUENCY))
lcd.clear();
lcd.setCursor(0,0);
lcd.print("VOL. :0.00");
lcd.setCursor(0,1);
lcd.print("TOTAL:");
lcd.print( TOTAL);
lcd.print("L");
else
lcd.println(FREQUENCY);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("VOL.: ");
lcd.print(WATER);
lcd.print(" L/M");
lcd.setCursor(0,1);
lcd.print("TOTAL:");
lcd.print( TOTAL);
lcd.print("L");
delay(3000);
TOTAL++;
//==================================================================================
//===================================================================================
======
void SendMessage()
waterFlow();
delay(1000);
mySerial.print(TOTAL);
mySerial.println("litres");
delay(100);
delay(1000);