forked from taps1197/Smart-City
-
Notifications
You must be signed in to change notification settings - Fork 1
/
smartpark.py
97 lines (94 loc) · 2.11 KB
/
smartpark.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
import xlrd as xr
import xlwt as xw
import serial
import vlc
import time as t
import RPi.GPIO as rp
rp.setwarnings(False)
rp.setmode(rp.BOARD)
rp.setup(7,rp.OUT)
rp.setup(11,rp.IN)
rp.setup(13,rp.OUT)
rp.setup(15,rp.OUT)
rp.setup(19,rp.OUT)
rp.setup(23,rp.OUT)
rp.setup(21,rp.IN)
name=[] #list
nc=5
s=serial.Serial('/dev/ttyUSB0')
d=s.read(12) #card scan
print (d)
n=0
print('CARD ACCEPTED')
na=input('NAME:')
name.append(na)
# instance=vlc.Instance()
# player=instance.media_player_new()
# ch='welcome.mp3'
# media=instance.media_new(ch)
# media.get_mrl()
# player.set_media(media)
# player.play()
t.sleep(5)
wb=xw.Workbook() #for MS excel
shw=wb.add_sheet('sheet1') #data type:-not a list but a represntation of excel
for i in range(0,len(name)):
shw.write(0,i,name[i])
wb.save('Parking.xls')
# instance=vlc.Instance()
# player=instance.media_player_new()
# ch='welcome1.mp3'
# media=instance.media_new(ch)
# media.get_mrl()
# player.set_media(media)
# player.play()
t.sleep(2)
rp.output(7,1)
rp.output(15,0)
t.sleep(10)
rp.output(7,0)
rp.output(15,1)
t.sleep(5)
rp.output(15,0)
rp.output(19,1)
t.sleep(0.0001)
rp.output(19,0)
while(n<5):
while(rp.input(11)==0):
pass
st=t.time()
while(rp.input(11)==1):
pass
sot=t.time()
tt=sot-st
d=(34300*tt)/2 #distance calcluation uisng ultrasonic sensor
if(d<100):
print('car is at distance',d,'cm')
n=n+1
if( d<=5):
print('The Car is parked rightly')
rp.output(13,1) #LED
t.sleep(10)
rp.output(13,0)
t.sleep(2)
rp.output(23,1) # LED for bigger screeen if parking space is available
t.sleep(0.0001)
rp.output(23, 0) # Barracide if parking space is full
while(n<5):
while(rp.input(21)==0):
pass
st=t.time()
while(rp.input(21)==1):
pass
sot=t.time()
tt=sot-st
d=(34300*tt)/2
if(d<100):
print('car is at distance',d,'cm')
n=n+1
if( d<=5):
print('The Car is parked rightly')
rp.output(13,1)
t.sleep(10)
rp.output(13,0)
t.sleep(2)