年月日 | 作業記録 |
---|---|
2024/7/12 | RobotCar車体Kit/MotorドライバーL298d購入 |
2024/8/27 | 動画撮影 |
この動画では、以下のモーター動作が順番に行われます:
各動作は、5秒間ずつ実行されます。
from gpiozero import PWMOutputDevice
from gpiozero import DigitalOutputDevice
from time import sleep
PWM_DRIVE_RIGHT = 18 # ENB - H-Bridge enable pin
FORWARD_RIGHT_PIN = 14 # IN1 - Forward Drive
REVERSE_RIGHT_PIN = 15 # IN2 - Reverse Drive
driveRight = PWMOutputDevice(PWM_DRIVE_RIGHT, active_high=True, initial_value=0, frequency=1000)
forwardRight = PWMOutputDevice(FORWARD_RIGHT_PIN)
reverseRight = PWMOutputDevice(REVERSE_RIGHT_PIN)
def allStop():
forwardRight.value = False
reverseRight.value = False
driveRight.value = 0
def forwardDrive():
forwardRight.value = True
reverseRight.value = False
driveRight.value = 1.0
def forwardDrive_Slowly():
forwardRight.value = True
reverseRight.value = False
driveRight.value = 0.5
def reverseDrive():
forwardRight.value = False
reverseRight.value = True
driveRight.value = 1.0
def main():
allStop()
forwardDrive()
sleep(5)
forwardDrive_Slowly()
sleep(5)
reverseDrive()
sleep(5)
allStop()
if __name__ == "__main__":
""" This is executed when run from the command line """
main()