forked from Shellowb/BioMixer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.py
More file actions
57 lines (49 loc) · 1.23 KB
/
controller.py
File metadata and controls
57 lines (49 loc) · 1.23 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
51
52
53
54
55
56
57
"""
Main settings and functions to work from the server to Arduino Devices.
Developed in practical work for FabLab Uchile
danisa@fablab.uchile.cl
By: Marcelo Becerra A.
marcelo.becerra@ug.uchile.cl
"""
import serial
import io
import time
# Water, kitchen Arduino Port
ser = serial.Serial("/dev/ttyUSB0",9600, timeout= 0.5)
# powder Arduino Port
ser1 = serial.Serial("/dev/ttyACM1",9600, timeout= 0.5)
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
#time.sleep(3)
# Testing Arduino led
def check_led():
ser.write(b'c\n')
ser.flush()
# Turn on the kitchen
def turn_on_pot():
ser.write(b'be\n')
ser.flush()
ser.write(b'c')
#print(ser.readline())
ser.flush()
# Show information from serial port
def show():
ser.write(b'c\n')
a= str(ser.readline())
c = float(a[2])
c = c + float(a[4])/10 + float(a[5])/100
print(a)
return c
# Send Proportions of materials to the machine
def send_proportions(agar,water,glyc):
start='a'
end = 'e'
wq = start + str(water) + end
wq = wq.encode('utf-8')
aq = start + str(agar) + end
aq = aq.encode('utf-8')
gq = start + str(glyc) + end
gq = gq.encode('utf-8')
print(wq, aq, gq)
ser.write(wq)
#ser.write(aq)
#ser.write(gq)