1
2#include <LiquidCrystal.h>
3
4char str[34],L=2;
5int temp=0,i=0;
6int Pass=0,p=0;
7 int c,x,d;
8const int rs = 5, en = 3, d4 = A5, d5 = A4, d6 = A3, d7 = A2;
9LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
10
11void setup()
12{
13 Serial.begin(9600);
14 pinMode(A1,OUTPUT);
15 pinMode(A0,OUTPUT);
16 pinMode(4,OUTPUT);
17
18 digitalWrite(A1,LOW);
19 digitalWrite(A0,LOW);
20 digitalWrite(4,LOW);
21
22 lcd.begin(16, 2);
23
24
25}
26
27
28void loop()
29{
30 if(temp==1)
31 {
32 check();
33 temp=0;
34 i=0;
35 delay(1000);
36 }
37
38}
39
40void serialEvent()
41 {
42 while (Serial.available())
43 {
44 char inChar=Serial.read();
45 str[i++]=inChar;
46 delay(10);
47 }
48 for (p=i+1;p<34;p++)
49 {
50 str[i++]=32;
51 }
52 temp=1;
53 Serial.write(str);
54 lcd.setCursor(0, 0);
55 lcd.print(str);
56 if(i>16)
57 {
58 d=16;
59 for (x=0;x<=17;x++)
60 {
61 lcd.setCursor(x,2);
62 lcd.print(str[d]);
63 d++;
64 }
65 }
66 }
67
68void check()
69{
70if(!(strncmp(str,"1",1)))
71 {
72 digitalWrite(A1,50);
73 lcd.clear();
74 }
75 else if(!(strncmp(str,"2",1)))
76 {
77 digitalWrite(A1,LOW);
78 lcd.clear();
79 }
80}
81