digital-pipette / scripts /digital_pipette_picow_basic.py
sgbaird's picture
chore: Add Actuator Control Panel implementation using Streamlit and MQTT and basic scripts and reqs file
e56c4e3
raw
history blame contribute delete
651 Bytes
import utime
from machine import PWM, Pin
# Setup PWM
pwm = PWM(Pin(0)) # Use the appropriate GPIO pin
pwm.freq(50) # 50 Hz frequency
def set_position(pulse_ms):
duty = int((pulse_ms / 20.0) * 65535)
pwm.duty_u16(duty)
# Example to set the actuator to different positions
set_position(1.1) # Almost full retraction
utime.sleep(5)
set_position(1.5) # Halfway
utime.sleep(5)
set_position(1.9) # Almost full extension
utime.sleep(5)
set_position(1.1) # Almost full retraction
utime.sleep(5)
set_position(1.5) # Halfway
utime.sleep(5)
# Add your logic to set it to the desired intermediate positions
pwm.deinit() # Deinitialize PWM