testcode, to test engineclass
This commit is contained in:
parent
f739f34f75
commit
8dc6be6cfc
@ -1,13 +1,22 @@
|
|||||||
####################################################################
|
####################################################################
|
||||||
# This file contains the code to control the motors of the robot.
|
# This file contains the code to control the motors of the robot.
|
||||||
#
|
#
|
||||||
# The motors are controlled using PWM signals.
|
# 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 L298N motor driver.
|
||||||
# The code is designed to work with the Raspberry Pi 5.
|
# The code is designed to work with the Raspberry Pi 5.
|
||||||
######################################################################
|
######################################################################
|
||||||
from gpiozero import Motor, PWMOutputDevice
|
from gpiozero import Motor, PWMOutputDevice
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
class Motor:
|
class Motor:
|
||||||
def __init__(self, motor_pin1, motor_pin2, pwm_pin):
|
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
|
||||||
|
|||||||
@ -2,9 +2,28 @@
|
|||||||
# This file contains the main code to control the robot.
|
# This file contains the main code to control the robot.
|
||||||
#
|
#
|
||||||
####################################################################
|
####################################################################
|
||||||
|
from motors import Motor
|
||||||
|
|
||||||
|
|
||||||
def main():
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user