-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTrafficviolation.py
184 lines (134 loc) · 3.03 KB
/
Trafficviolation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define ir 2
#define r 3
#define buz 4
#define sw 5
#define re 6
#define ye 7
#define ge 8
int a,b,c;
void setup()
{
Serial.begin(9600);
lcd.begin();
// Turn on the blacklight and print a message.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Smart E-Challan");
lcd.setCursor(3,1);
lcd.print("For Smart City");
delay(2000);
lcd.clear();
pinMode(ir,INPUT);
pinMode(sw,INPUT);
pinMode(r,OUTPUT);
pinMode(buz,OUTPUT);
pinMode(re,OUTPUT);
pinMode(ye,OUTPUT);
pinMode(ge,OUTPUT);
digitalWrite(r,1);
digitalWrite(buz,0);
digitalWrite(re,0);
digitalWrite(ye,0);
digitalWrite(ge,0);
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("Smart E-Challan");
lcd.setCursor(3,1);
lcd.print("For Smart City");
delay(500);
lcd.clear();
a=digitalRead(ir);
b=digitalRead(sw);
if(b==1)
{
digitalWrite(ye,0);
digitalWrite(ge,0);
digitalWrite(re,1);
digitalWrite(r,0);
if(a==1)
{
SendMessage();
SendMessage1();
digitalWrite(buz,1);
delay(1000);
digitalWrite(buz,0);
delay(1000);
}
if(a==0)
{
Serial.print("nort");
digitalWrite(buz,0);
}
}
if(b==0)
{
digitalWrite(buz,0);
digitalWrite(ye,1);
digitalWrite(ge,0);
digitalWrite(re,0);
digitalWrite(r,1);
delay(2000);
digitalWrite(buz,0);
digitalWrite(ye,0);
digitalWrite(ge,1);
digitalWrite(re,0);
digitalWrite(r,1);
delay(2000);
}
}
void SendMessage()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" ALERT ");
lcd.setCursor(0,1);
lcd.print("VIOLATION DETECTED");
delay(2000);
Serial.println("AT+CMGF=1"); // sending command code
delay(1000);
Serial.println("AT+CMGS=\"+919284161989\"\r"); // Replace * with mobile number
delay(1000);
Serial.print(" ALERT ");
Serial.println(" ");
Serial.println("Your fine amount of 299 leived for Traffic Violation Pay to Aviod Auto Debit"); // The SMS text you want to send
Serial.println(" ");
Serial.println(" ");
//
delay(100);
Serial.println((char)26);
delay(1000);
lcd.clear();
lcd.print("SMS SENT");
delay(1000);
}
void SendMessage1()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" ALERT ");
lcd.setCursor(0,1);
lcd.print("VIOLATION DETECTED");
delay(2000);
Serial.println("AT+CMGF=1"); // sending command code
delay(1000);
Serial.println("AT+CMGS=\"+918087114548\"\r"); // Replace * with mobile number
delay(1000);
Serial.print(" ALERT ");
Serial.println(" ");
Serial.println("Your fine amount of 299 leived for Traffic Violation Pay to Aviod Auto Debit"); // The SMS text you want to send
Serial.println(" ");
Serial.println(" ");
//
delay(100);
Serial.println((char)26);
delay(1000);
lcd.clear();
lcd.print("SMS SENT");
delay(1000);
}