From d3edd355dc02b14a31b5280bb10589966b91d8a6 Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Thu, 17 Aug 2017 23:02:54 +0200 Subject: [PATCH] Add crazy code and docs --- README.org | 17 +++++++++++++++++ code/main.py | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/README.org b/README.org index 9818de6..f5f89c6 100644 --- a/README.org +++ b/README.org @@ -59,3 +59,20 @@ while True: | Gnd | GND | | In1 | D5 | | In2 | D6 | + +*** Set up relays +#+begin_src python +import main + +# Use this to reset the state of the relay +main.resetRelay() + +# Move table up +main.toggleRaiseUp() + +# Move table down +main.toggleLowerDown() + +# To go up and down and measure distance and stuff at the same time +main.goCrazy() +#+end_src diff --git a/code/main.py b/code/main.py index 62346d5..b230058 100644 --- a/code/main.py +++ b/code/main.py @@ -34,3 +34,25 @@ def toggleLowerDown(): relayDown = machine.Pin(pins.D6, mode=machine.Pin.OUT) relayDown.value(not relayDown.value()) + + +def goCrazy(): + resetRelay() + + while True: + print("Lowest Distance: " + str(getDistance())) + print("Movement: " + str(getMovement())) + + toggleRaiseUp() + + time.sleep(3) + + print("Highest Distance: " + str(getDistance())) + print("Movement: " + str(getMovement())) + + toggleRaiseUp() + toggleLowerDown() + + time.sleep(3) + + toggleLowerDown()