Skip to content

Commit

Permalink
pump scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sgbaird committed Sep 12, 2024
1 parent 5bc496c commit 5b4088d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/public_mqtt_sdl_demo/scripts/pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from machine import PWM, Pin

pump = PWM(Pin(0))
pump = PWM(Pin(3))


def run(pump, power):
Expand Down
30 changes: 30 additions & 0 deletions src/public_mqtt_sdl_demo/scripts/pumps_loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import random
from time import sleep

from machine import PWM, Pin

pumps = [PWM(Pin(i)) for i in range(4)]


def run(pump, power):
assert 0 <= power <= 1, "power must be between 0 and 1"
pump.freq(20000)
pump.duty_u16(round(65535 * power))


def run_exp():
for pump in pumps:
pw = random.random()
print(pw)
run(pump, pw)
sleep(10.25)


run_exp()
[run(pump, 0.0) for pump in pumps]
# while True:
# run_exp()
## sleep(50000)

# [run(pump, 0.0) for pump in pumps]
# sleep(50000)

0 comments on commit 5b4088d

Please sign in to comment.