-
Notifications
You must be signed in to change notification settings - Fork 0
/
control_tiempo_y_brillo.py
43 lines (34 loc) · 1.12 KB
/
control_tiempo_y_brillo.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
from pyfirmata2 import Arduino,util
import tkinter
from time import sleep
board = Arduino('/dev/cu.usbmodem14201')
PINS = [0]
def onStartButtonPress():
timePeriod = timePeriodEntry.get()
timePeriod = float(timePeriod)
ledBrightness = brightnessScale.get()
ledBrightness = float(ledBrightness)
startButton.config(state=tkinter.DISABLED)
board.get_pin('d:11:p').write(ledBrightness/100.0)
sleep(timePeriod)
######board.get_pin('d:11:p').write(0)
startButton.config(state=tkinter.ACTIVE)
top = tkinter.Tk()
top.title("Tiempo:")
timePeriodEntry = tkinter.Entry(top, bd = 5, width = 25)
timePeriodEntry.pack()
timePeriodEntry.focus_set()
brightnessScale = tkinter.Scale(top, from_=0, to =100, orient=tkinter.HORIZONTAL)
brightnessScale.pack()
startButton = tkinter.Button(top, text="Start", command= onStartButtonPress)
startButton.pack()
top.mainloop()
print ("Conectando al Arduino...")
it = util.Iterator(board)
it.start()
for pin in PINS:
board.analog[pin].enable_reporting()
while 1:
for pin in PINS:
print (f"Pin a{pin} : {board.analog[pin].read()}")
board.pass_time(1)