motor_control_hbridge.py

# この作品はMITライセンスの下で提供されています。
# Copyright (c) 2013-2024 OpenMV LLC. 全著作権所有。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# モーター制御の例
#
# この例は、Hブリッジモーターコントローラの制御方法を示します。
# "P0"/"P7"は左モーターのHブリッジを制御し、
# "P2"/"P8"は右モーターのHブリッジを制御します。

import time
from machine import Pin

p0 = Pin("P0", Pin.OUT)
p2 = Pin("P2", Pin.OUT)
p7 = Pin("P7", Pin.OUT)
p8 = Pin("P8", Pin.OUT)

p0.value(0)
p2.value(0)
p7.value(0)
p8.value(0)

while True:
    p0.value(not p0.value())
    time.sleep_ms(2000)
    p7.value(not p7.value())
    time.sleep_ms(2000)
    p0.value(not p0.value())
    time.sleep_ms(2000)
    p7.value(not p7.value())
    time.sleep_ms(2000)

    p2.value(not p2.value())
    time.sleep_ms(2000)
    p8.value(not p8.value())
    time.sleep_ms(2000)
    p2.value(not p2.value())
    time.sleep_ms(2000)
    p8.value(not p8.value())
    time.sleep_ms(2000)

results matching ""

    No results matching ""