Adafruit_Learning_System_Gu.../MetroX_CircuitPython/motor/code.py
2022-02-22 13:45:02 -05:00

32 lines
564 B
Python
Executable file

# SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
'MOTOR.py'.
=================================================
spin a DC MOTOR using digitalio
"""
import time
import board
import digitalio
MOTOR_PIN = board.D9
MOTOR = digitalio.DigitalInOut(MOTOR_PIN)
MOTOR.switch_to_output()
def motor_on_then_off():
"""toggles the motor."""
on_time = 2.5
off_time = 1.0
MOTOR.value = True
time.sleep(on_time)
MOTOR.value = False
time.sleep(off_time)
while True:
motor_on_then_off()