-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_pilote.py
More file actions
51 lines (42 loc) · 1.05 KB
/
command_pilote.py
File metadata and controls
51 lines (42 loc) · 1.05 KB
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
import RPi.GPIO as GPIO ## Import GPIO library
import time
import sys
import select
# States
# 0 : Confort
# 1 : (MN) Arrêt
# 2 : (MP) Hors-gel
# 3 : Eco
PIN_MP=16
PIN_MN=18
state = 0
GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
GPIO.setup(PIN_MP, GPIO.OUT)
GPIO.output(PIN_MP,False)
GPIO.setup(PIN_MN,GPIO.OUT)
GPIO.output(PIN_MN,False)
def setState(state):
print ("State " + str(state))
if state == 0:
GPIO.output(PIN_MP, False)
GPIO.output(PIN_MN, False)
elif state == 1:
GPIO.output(PIN_MP, False)
GPIO.output(PIN_MN, True)
elif state == 2:
GPIO.output(PIN_MP, True)
GPIO.output(PIN_MN, False)
elif state == 3:
GPIO.output(PIN_MP, True)
GPIO.output(PIN_MN, True)
try:
while True:
input = sys.stdin.readline()
print("Read : " + input)
try:
state = int(input)
setState(state)
except:
print("Invalid input : " + input)
finally:
GPIO.cleanup()