int sutp = 0, p = 0,a=0;
int m1 = 0, m2 = 0,m3=0,m4=0,m6=0;
#include <EEPROM.h>
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the Arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 7, d5 = 3, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// set up the LCD's number of columns and rows:
void setup() {
lcd.begin(16,2);
Serial.begin(9600);
// put your setup code here, to run once:
pinMode(4, INPUT_PULLUP); //ok
pinMode(5, INPUT_PULLUP); //+
pinMode(6, INPUT_PULLUP); //-
a=EEPROM.read(10);
if(a>11){
a=0;
}
}
void loop() {
// put your main code here, to run repeatedly:
while (digitalRead(4) == LOW && digitalRead(5) == LOW && m1 == 0 ) {
sutp = 1;
m1 = 1;
delay(100);
}
if (sutp == 1) {
while (digitalRead(4) == LOW && m2 == 0) {
p = p + 1;
m2=1;
if (p > 7) {
p = 0;
}
}
while (digitalRead(4)==HIGH && m2==1){
m2=0;
}
}
if (p==7){
while(digitalRead(5)==LOW && digitalRead(6)==LOW && m6==0){
sutp=0;
p=0;
m6=1;
m1=0;
EEPROM.update(10,a);
}
while (digitalRead(5)==LOW && digitalRead(6)==LOW ){
m6=0;
}
}
if (p==2){
while (digitalRead(5)==LOW && m3==0){
a=a+1;
m3=1;
if (a>10){
a=0;
/* lcd.setCursor(0,0);
lcd.print(" "); */
}
}
if (digitalRead(5)==HIGH){
m3=0;
}
while (digitalRead(6)==LOW && m4==0){
a=a-1;
m4=1;
if (a==-1){
a=10;
/*lcd.setCursor(0,0);
lcd.print(" ");*/
}
}
if (digitalRead (6)==HIGH){
m4=0;
}
}
Serial.print("sutp= ");
Serial.println(sutp);
Serial.print("p= ");
Serial.println(p);
Serial.print("a= ");
Serial.println(a);
if(sutp==1){
lcd.setCursor(13,0);
lcd.print("P=");
lcd.setCursor(15,0);
lcd.print(p);
if(p==0){
lcd.setCursor(0,0);
lcd.print("Tumrachar1= ");
lcd.setCursor(0,1);
lcd.print(" ");
}
if(p==1){
lcd.setCursor(0,0);
lcd.print("Tumrachar2= ");
lcd.setCursor(0,1);
lcd.print(" ");
}
if(p==2){
lcd.setCursor(0,0);
lcd.print("Tumrachar= ");
if(a<11){
lcd.setCursor(1,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(a);
}
else {
lcd.setCursor(0,1);
lcd.print(a);
lcd.setCursor(2,1);
lcd.print(" ");
}
}
if(p==3){
}
if(p==4){
}
if(p==5){
}
if(p==6){
}
if(p==7){
lcd.setCursor(0,0);
lcd.print("SAVE DATA ");
lcd.setCursor(0,1);
lcd.print("YES DON AND UP");
}
}
if(sutp==0){
lcd.setCursor(0,0);
lcd.print("Normal ");
lcd.setCursor(0,1);
lcd.print(" ");
}
}