playzing/trigger_once_arduino.py
Cocktail Frank 4be9ddb561 Add doc for card dispenser and Arduino dispenser script
The Arduino dispenser script sends a single dispense signal every run

Add incomplete Python packaging configuration file
2026-07-05 13:24:42 -04:00

35 lines
860 B
Python

import time
import sys
from Arduino import Arduino # type: ignore [import-untyped, import-not-found]
PIN_DISPENSE = 3
PIN_GROUND = 4
if __name__ == "__main__":
try:
board = Arduino()
# Initialize dispenser in and turn off
board.pinMode(PIN_DISPENSE, "OUTPUT")
board.digitalWrite(PIN_DISPENSE, "LOW")
# Simulate ground with a GPIO pin
board.pinMode(PIN_GROUND, "OUTPUT")
board.digitalWrite(PIN_GROUND, "LOW")
except Exception as error:
print(f"No Arduino detected, so not initializing Arduino board. (System message: {error})")
sys.exit(0)
# Send a trigger
board.digitalWrite(PIN_DISPENSE, "HIGH")
print("Activate output signal")
time.sleep(0.5)
# Cut off the trigger signal
board.digitalWrite(PIN_DISPENSE, "LOW")
print("End output signal")