Beruflich Dokumente
Kultur Dokumente
h>
#include <EtherCard.h>
#include <net.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
void setup()
{
pinMode(mot1, OUTPUT);
pinMode(mot2, OUTPUT);
pinMode(sol1, OUTPUT);
pinMode(alert, OUTPUT);
mySerial.begin(9600);
mySerial1.begin(9600);
Serial.begin(9600);
for (i = 0; i <= 3; i++)
{
pinMode(row[i], OUTPUT);
pinMode(col[i], INPUT);
digitalWrite(col[i], HIGH);
}
lcd.begin(16, 2);
lcd.print("show your card");
// thingspeak code
Serial.begin(9600);
}
void loop()
{
for (i = 0; i <= 3; i++)
{
digitalWrite(row[0], HIGH);
digitalWrite(row[1], HIGH);
digitalWrite(row[2], HIGH);
digitalWrite(row[3], HIGH);
digitalWrite(row[i], LOW);
for (j = 0; j <= 3; j++)
{
col_scan = digitalRead(col[j]);
if (col_scan == LOW)
{
keypress(i, j);
delay(300);
}
}
}
if (mySerial.available() > 0)
{
j1 = mySerial.read();
tag[i1] = j1;
i1++;
}
if (i1 == 8 )
{
lcd.clear();
lcd.print("enter password ");
}
if (pass == 0)
{
lcd.clear();
lcd.print("******** ......");
delay(2000);
lcd.clear();
for (int i = 0; i <= 2; i++)
{
c = 0;
m1 = i;
for (int k = 0; k <= 7; k++)
{
//Serial.println(tag[k]);
if (tag[k] - key2[i][k] == 48 && key[k] - passo[i][k] == 0)
c++;
}
//Serial.print(c);
if (c == 8)
goto l;
}
l: if (c == 8)
{ pass = 1;
c = 0;
switch (m1)
{
case 0: if (tRice1 >= 500 || toil1 >= 500)
{
lcd.print(" Noor Adiba Mam");
name1 = 1111;
lcd.setCursor(0, 1);
lcd.print("Project Guide");
delay(5000);
lcd.clear();
lcd.print("Enter ur Choice");
lcd.setCursor(0, 1);
lcd.print("1:Rice 2:Oil");
ltt = 1;
if (tRice1 >= 500)
{
if (sol2 == 1)
{
lt = 1;
lcd.clear();
lcd.print(" Rice");
item = 1;
lcd.setCursor(0, 1);
lcd.print("3:500gm 4:1000gm");
if (sol3 == 1 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("500gm");
qty = 500;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(5000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice1 = tRice1 - 500;
delay(3000);
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol9 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
else if (sol3 == 2 && tRice1 >= 1000 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("1000gm");
item = 1;
qty = 1000;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(10000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice1 = tRice1 - 1000;
delay(3000);
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol9 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
if (toil1 >= 500)
{
if (sol2 == 2)
{
lt = 1;
lcd.clear();
lcd.print("Oil");
item = 2;
lcd.setCursor(0, 1);
lcd.print("3:500ml 4:1000ml");
if (sol3 == 1)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("500ml");
qty = 500;
senddata(name1, item, qty);
delay(15000);
digitalWrite(sol1, LOW);
lcd.clear();
toil1 = toil1 - 500;
delay(3000);
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol9 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
if (sol3 == 2 && toil1 >= 1000)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("1000ml");
item = 2;
qty = 1000;
senddata(name1, item, qty);
delay(25000);
digitalWrite(sol1, LOW);
lcd.clear();
toil1 = toil1 - 1000;
delay(3000);
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol9 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
}
else
{
lcd.clear();
sol9 = 1;
lcd.print("Come next month");
delay(3000);
goto ly;
}
break;
case 1: if (tRice2 >= 500 || toil2 >= 500)
{
lcd.print(" Hanu");
lcd.setCursor(0, 1);
lcd.print("Red Card");
delay(3000);
lcd.clear();
lcd.print("Enter ur Choice");
lcd.setCursor(0, 1);
lcd.print("1:Rice 2:Oil");
ltt = 1;
if (tRice2 >= 500)
{
if (sol2 == 1)
{
lt = 1;
lcd.clear();
lcd.print(" Rice");
lcd.setCursor(0, 1);
lcd.print("3:500gm 4:1000gm");
if (sol3 == 1 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("500gm");
name1 = 2222;
item = 1;
qty = 500;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(5000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice2 = tRice2 - 500;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol10 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
else if (sol3 == 2 && tRice2 >= 1000 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("1000gm");
qty = 1000;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(10000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice2 = tRice2 - 1000;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol10 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
if (toil2 >= 500)
{
if (sol2 == 2)
{
lt = 1;
lcd.clear();
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("3:500ml 4:1000ml");
if (sol3 == 1)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("500ml");
item = 2;
qty = 500;
senddata(name1, item, qty);
delay(5000);
digitalWrite(sol1, LOW);
lcd.clear();
toil2 = toil2 - 500;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol10 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
if (sol3 == 2 && toil2 >= 1000)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("1000ml");
item = 2;
qty = 1000;
senddata(name1, item, qty);
delay(10000);
digitalWrite(sol1, LOW);
lcd.clear();
toil2 = toil2 - 1000;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol10 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
}
else
{
lcd.clear();
sol9 = 1;
lcd.print("Come next month");
delay(3000);
goto ly;
}
break;
case 2: if (tRice3 >= 500 || toil3 >= 500)
{
lcd.print(" Panditji");
name1 = 3333;
lcd.setCursor(0, 1);
lcd.print("yellow card");
delay(5000);
lcd.clear();
lcd.print("Enter ur Choice");
lcd.setCursor(0, 1);
lcd.print("1:Rice 2:Oil");
ltt = 1;
if (tRice3 >= 500)
{
if (sol2 == 1)
{
lt = 1;
lcd.clear();
lcd.print(" Rice");
lcd.setCursor(0, 1);
lcd.print("3:500gm 4:1000gm");
if (sol3 == 1 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("500gm");
item = 1;
qty = 500;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(5000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice3 = tRice3 - 500;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol11 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
else if (sol3 == 2 && tRice3 >= 1000 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("1000gm");
item = 1;
qty = 1000;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(10000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice3 = tRice3 - 1000;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol11 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
if (toil3 >= 500)
{
if (sol2 == 2)
{
lt = 1;
lcd.clear();
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("3:500ml 4:1000ml");
if (sol3 == 1)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("500ml");
item = 2;
qty = 500;
senddata(name1, item, qty);
delay(5000);
digitalWrite(sol1, LOW);
lcd.clear();
toil3 = toil3 - 500;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol11 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
if (sol3 == 2 && toil3 >= 1000)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("1000ml");
item = 2;
qty = 1000;
senddata(name1, item, qty);
delay(10000);
digitalWrite(sol1, LOW);
lcd.clear();
toil3 = toil3 - 1000;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol11 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
}
else
{
lcd.clear();
sol9 = 1;
lcd.print("Come next month");
delay(3000);
goto ly;
}
}
}
else
{
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("wrong card");
digitalWrite(alert, HIGH);
delay(3000);
digitalWrite(alert, LOW);
pass = 1;
sol9 = 1;
lcd.clear();
}
}
ly : if (sol9 == 1)
{
lcd.clear();
lcd.print("Thank you");
delay(3000);
i = 0;
lcd.clear();
if (tRice1 < 500)
lcd.print("Monthly ItemOver");
if (toil1 < 500)
lcd.print("Monthly Oil Over");
for (int g = 0; g <= 7; g++)
key[g] = 0, tag[k] = 0;
sol9 = 0; i1 = 0, m = 0, ltt = 0;
sol2 = 0;
delay(3000);
lcd.clear();
lcd.print("Show your card");
}
if (sol10 == 1)
{
lcd.clear();
lcd.print("Thank you");
delay(3000);
i = 0;
lcd.clear();
if (tRice2 < 500)
lcd.print("Monthly ItemOver");
if (toil2 < 500)
lcd.print("Monthly Oil Over");
for (int g = 0; g <= 7; g++)
key[g] = 0, tag[k] = 0;
sol10 = 0; i1 = 0, m = 0, ltt = 0;
sol2 = 0;
delay(3000);
lcd.clear();
lcd.print("Show your card");
}
if (sol11 == 1)
{
lcd.clear();
lcd.print("Thank you");
delay(3000);
i = 0;
lcd.clear();
if (tRice3 < 500)
lcd.print("Monthly ItemOver");
if (toil3 < 500)
lcd.print("Monthly Oil Over");
for (int g = 0; g <= 7; g++)
key[g] = 0, tag[k] = 0;
sol2 = 0;
sol11 = 0; i1 = 0, m = 0, ltt = 0;
delay(3000);
lcd.clear();
lcd.print("Show your card");
}
}
void keypress(int i, int j)
{
lcd.clear();
if (i == 0 && j == 0)
{
lcd.print("1");
key[m] = 1; m++;
if (ltt == 1)
{
sol2 = 1, pass = 0, pp = 0;
}
if (tRice1 < 500 && ltt == 1 && m1 == 0 )
{
sol9 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
if (tRice2 < 500 && ltt == 1 && m1 == 1 )
{
sol10 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
if (tRice3 < 50 && ltt == 1 && m1 == 2)
{
sol11 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
}
if (i == 0 && j == 1)
{
lcd.print("2");
key[m] = 2; m++;
if (ltt == 1)
{
sol2 = 2, pass = 0, pp = 0;
}
if (toil1 < 500 && ltt == 1 && m1 == 0)
{
sol9 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
if (toil2 < 500 && ltt == 1 && m1 == 1)
{
sol10 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
if (toil3 < 500 && ltt == 1 && m1 == 2)
{
sol11 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
}
if (i == 0 && j == 2)
{
lcd.print("3");
key[m] = 3; m++;
if (lt == 1)
{
sol3 = 1, pass = 0;
}
}
if (i == 1 && j == 0)
{
lcd.print("4");
key[m] = 4; m++;
if (lt == 1)
{
sol3 = 2, pass = 0;
}
}
if (i == 1 && j == 1)
{
lcd.print("5");
key[m] = 5; m++;
}
if (i == 1 && j == 2)
{
lcd.print("6");
key[m] = 6; m++;
}
if (i == 2 && j == 0)
{
lcd.print("7");
key[m] = 7; m++;
}
if (i == 2 && j == 1)
{
lcd.print("8");
key[m] = 8; m++;
}
if (i == 2 && j == 2)
{
lcd.print("9");
key[m] = 9; m++;
}
if (i == 3 && j == 1)
{
lcd.print("0");
key[m] = 0; m++;
if (ppp == 1)
{
sol9 = 1, pass = 0;
lt = 0;
ltt = 0;
}
}
if (i == 3 && j == 2)
{
lcd.print("#");
pass = 0;
}
void senddata(int a, int b, int c)
{
//if correct answer is not received then re-initialize ethernet module
if (res > 220) {
initialize_ethernet();
}
res = res + 1;
ether.packetLoop(ether.packetReceive());