Commit c2605876af79286ab0bc1203fe0353e75302b3ce

Authored by Raymond Bakke Pedersen
1 parent f60f9c14

El Kode la finale

Showing 1 changed file with 16 additions and 14 deletions   Show diff stats
1 import serial 1 import serial
2 import RPi.GPIO as GPIO 2 import RPi.GPIO as GPIO
3 import time 3 import time
  4 +import os
4 5
5 -out_a = 16  
6 -out_b = 12  
7 -in_a = 20  
8 -in_b = 21 6 +out_a = 6
  7 +out_b = 13
  8 +in_a = 19
  9 +in_b = 26
9 10
10 GPIO.setwarnings(False) 11 GPIO.setwarnings(False)
11 GPIO.setmode(GPIO.BCM) 12 GPIO.setmode(GPIO.BCM)
@@ -28,9 +29,9 @@ while(1): @@ -28,9 +29,9 @@ while(1):
28 tid = d_in[1] 29 tid = d_in[1]
29 time = tid[:2] 30 time = tid[:2]
30 min = tid[2:4] 31 min = tid[2:4]
31 - ar = now[3:]  
32 - mane=now[1:3]  
33 - dag = now[:1] 32 + ar = now[4:]
  33 + mane=now[2:4]
  34 + dag = now[:2]
34 timezone = ("CET") 35 timezone = ("CET")
35 print('{}.{}.{}-{}:{} {}'.format(ar,mane,dag,time,min,timezone)) 36 print('{}.{}.{}-{}:{} {}'.format(ar,mane,dag,time,min,timezone))
36 oclock = ('{}.{}.{}-{}:{} {}'.format(ar,mane,dag,time,min,timezone)) 37 oclock = ('{}.{}.{}-{}:{} {}'.format(ar,mane,dag,time,min,timezone))
@@ -53,17 +54,18 @@ while(1): @@ -53,17 +54,18 @@ while(1):
53 print('{},{}'.format(lofddg, d_in[6])) 54 print('{},{}'.format(lofddg, d_in[6]))
54 lon = ('{}'.format(lofddg)) 55 lon = ('{}'.format(lofddg))
55 56
56 - GPIO.output(out_b, 1)  
57 - if GPIO.input(in_a):  
58 - f = open ('/var/www/html/index.html','a')  
59 -# tilfil = d_in[3]+'\t'+d_in[5]+'\n'  
60 - locInfo = '\n' + '<p>' + oclock + '\n' + lat + '\t' + lon + '\t' + 'star3' +'\t' + '1' + '\n' + <\p> 57 + GPIO.output(out_b, 0)
  58 + GPIO.output(out_a, 0)
  59 + if GPIO.input(in_a)==0:
  60 + f = open ('/var/www/html/data.txt','a')
  61 + locInfo = oclock + '\n' + lat + '\t' + lon + '\t' + 'star3' +'\t' + '\n'
61 f.write(locInfo) 62 f.write(locInfo)
62 f.close() 63 f.close()
63 print("Location saved!") 64 print("Location saved!")
  65 + GPIO.output(out_b, 1)
  66 + elif GPIO.input(in_b)==0:
  67 + os.system("shutdown -h now")
64 GPIO.output(out_a, 1) 68 GPIO.output(out_a, 1)
65 - else:  
66 - GPIO.output(out_a, 0)  
67 else: 69 else:
68 print("ERROR: Data is invalid") 70 print("ERROR: Data is invalid")
69 71