File tree Expand file tree Collapse file tree 1 file changed +58
-7
lines changed
Expand file tree Collapse file tree 1 file changed +58
-7
lines changed Original file line number Diff line number Diff line change 1- import UDPLibrary
1+ import RPi .GPIO as GPIO
2+ from time import sleep
3+ import socket
24
3- """
4- Some setup things for raspbery.
5+ print ("Program Started.." )
56
6- """
7- bounding_boxes_coordinates = UDP .Receive ()
8- def generate_pwm (bounding_boxes_coordinates ):
9- print ("Generate PWM signals to related pins" )
7+ GPIO .setmode (GPIO .BCM )
8+ GPIO .setup (15 , GPIO .OUT )
9+ GPIO .setup (14 , GPIO .OUT )
10+ GPIO .setup (18 , GPIO .OUT )
11+
12+ right = GPIO .PWM (14 , 100 )
13+ mid = GPIO .PWM (15 , 100 )
14+ left = GPIO .PWM (18 , 100 )
15+
16+ left .start (100 )
17+ mid .start (100 )
18+ right .start (100 )
19+ pause_time = 0.02
20+
21+ ip = ""
22+ port = 8888
23+
24+ sock = socket .socket (socket .AF_INET , socket .SOCK_DGRAM )
25+ sock .bind ((ip , port ))
26+
27+ try :
28+ while True :
29+ data , addr = sock .recvfrom (1024 )
30+ print ("Receiving Message: {}" .format (data .decode ()))
31+ name = data .decode ()
32+ if name == "No_Detection" :
33+ en_sol .start (100 )
34+ orta .start (100 )
35+ en_sag .start (100 )
36+ print ("There is No Detection" )
37+
38+ if name == "first_pwm" :
39+ en_sol .start (20 )
40+ sleep (pause_time )
41+ print ("Left Headlight Going Down" )
42+
43+ if name == "second_pwm" :
44+ orta .start (20 )
45+ sleep (pause_time )
46+ print ("Middle Headlight Going Down" )
47+
48+ if name == "third_pwm" :
49+ en_sag .start (20 )
50+ sleep (pause_time )
51+ print ("Right Headlight Going Down" )
52+
53+ except KeyboardInterrupt :
54+ GPIO .cleanup ()
55+
56+ en_sag .stop ()
57+ orta .stop ()
58+ en_sol .stop ()
59+ GPIO .cleanup ()
60+
You can’t perform that action at this time.
0 commit comments