testcode, to test engineclass

This commit is contained in:
Andreas Jönsson 2025-05-07 14:58:15 +02:00
parent f739f34f75
commit 8dc6be6cfc
2 changed files with 33 additions and 5 deletions

View File

@ -1,13 +1,22 @@
####################################################################
# This file contains the code to control the motors of the robot.
#
#
# The motors are controlled using PWM signals.
# The code is designed to work with the L298N motor driver.
# The code is designed to work with the Raspberry Pi 5.
######################################################################
from gpiozero import Motor, PWMOutputDevice
from time import sleep
class Motor:
def __init__(self, motor_pin1, motor_pin2, pwm_pin):
pass
pass
def forward(self, speed):
pass
def backward(self, speed):
pass
def stop(self):
pass

View File

@ -2,9 +2,28 @@
# This file contains the main code to control the robot.
#
####################################################################
from motors import Motor
def main():
pass
leftMotor = Motor(17, 18, 22)
rightMotor = Motor(23, 24, 25)
while True:
# Move forward
leftMotor.forward(50)
rightMotor.forward(50)
# Move backward
wait(10)
leftMotor.backward(50)
rightMotor.backward(50)
# Stop
leftMotor.stop()
rightMotor.stop()
wait(50)
if __name__ == "__main__":
main()
main()