-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpruebas.py
76 lines (51 loc) · 1.24 KB
/
pruebas.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from sys import exit
import time
from time import sleep
import EasyMCP2221
from EasyMCP2221.Constants import *
mcp = EasyMCP2221.Device()
print(mcp.revision())
exit()
mcp.set_pin_function(
gp0 = "GPIO_IN",
gp1 = "GPIO_OUT",
gp2 = "GPIO_OUT",
gp3 = "GPIO_OUT")
# Output latching opamp circuit in GP0
while True:
if mcp.GPIO_read()[0]:
print("\nInt!\n")
mcp.set_pin_function(gp0 = "GPIO_OUT", out0 = 0)
mcp.set_pin_function(gp0 = "GPIO_IN")
if mcp.GPIO_read()[0]:
print("Can't clear it!")
sleep(2)
print(".")
def freq_meter():
mcp.set_pin_function(gp0 = "GPIO_IN")
start = time.time()
old = True
n = 0
while True:
input = mcp.GPIO_read()[0]
if input != old:
n = n + 1
if time.time() - start > 1:
print(int(n/2))
n = 0
start = time.time()
old = input
def counter():
mcp.set_pin_function(
gp0 = "GPIO_IN",
gp1 = "GPIO_IN",
gp2 = "GPIO_IN",
gp3 = "GPIO_IN")
c = 0
gp_old = mcp.GPIO_read()
while True:
gp = mcp.GPIO_read()
if not gp == gp_old:
c = c + 1
print(c)
gp_old = gp