mirror of
https://github.com/Wessel/Roommapper.git
synced 2026-07-22 07:47:10 +02:00
add second motor
This commit is contained in:
@@ -4,16 +4,16 @@ using System.Text;
|
||||
|
||||
namespace RobotController
|
||||
{
|
||||
class Motor(int stepOne, int dirOne, int stepTwo, int dirTwo)
|
||||
class Motor(int stepLeft, int dirLeft, int stepRight, int dirRight)
|
||||
{
|
||||
StringBuilder outputBuilder;
|
||||
ProcessStartInfo processStartInfo;
|
||||
Process process;
|
||||
|
||||
public int STEP_PIN1 { get; set; } = stepOne;
|
||||
public int DIR_PIN1 { get; set; } = dirOne;
|
||||
public int STEP_PIN2 { get; set; } = stepTwo;
|
||||
public int DIR_PIN2 { get; set; } = dirTwo;
|
||||
public int _stepLeft { get; set; } = stepLeft;
|
||||
public int _dirLeft { get; set; } = dirLeft;
|
||||
public int _stepRight { get; set; } = stepRight;
|
||||
public int _dirRight { get; set; } = dirRight;
|
||||
|
||||
public void Drive(bool direction, int steps)
|
||||
{
|
||||
|
||||
@@ -2,16 +2,45 @@ import RPi.GPIO as GPIO
|
||||
from RpiMotorLib import RpiMotorLib
|
||||
import time
|
||||
import sys
|
||||
import threading
|
||||
|
||||
direction= 23 # Direction (DIR) GPIO Pin
|
||||
step = 22 # Step GPIO Pin
|
||||
# Motor pins
|
||||
stepLeft = 22
|
||||
dirLeft = 23
|
||||
enableLeft = 24
|
||||
|
||||
stepRight = 25
|
||||
dirRight = 26
|
||||
enableRight = 27
|
||||
|
||||
def init():
|
||||
GPIO.setup(enableLeft, GPIO.OUT)
|
||||
GPIO.setup(enableRight, GPIO.OUT)
|
||||
|
||||
motorLeft = RpiMotorLib.A4988Nema(dirLeft, stepLeft, (21,21,21), "DRV8825")
|
||||
motorRight = RpiMotorLib.A4988Nema(dirRight, stepRight, (21,21,21), "DRV8825")
|
||||
|
||||
def drive():
|
||||
mymotortest = RpiMotorLib.A4988Nema(direction, step, (21,21,21), "DRV8825")
|
||||
GPIO.output(enableLeft, GPIO.LOW)
|
||||
motorLeft.motor_go(False, # True=Clockwise, False=Counter-Clockwise
|
||||
"Full" , # Step type (Full,Half,1/4,1/8,1/16,1/32)
|
||||
200, # number of steps
|
||||
.0005, # step delay [sec]
|
||||
False, # True = print verbose output
|
||||
.05) # initial delay [sec]
|
||||
GPIO.output(enableLeft, GPIO.HIGH)
|
||||
|
||||
mymotortest.motor_go(False, "Full", 200, 0.0005, False, .05)
|
||||
GPIO.output(enableRight, GPIO.LOW)
|
||||
motorRight.motor_go(False, # True=Clockwise, False=Counter-Clockwise
|
||||
"Full" , # Step type (Full,Half,1/4,1/8,1/16,1/32)
|
||||
200, # number of steps
|
||||
.0005, # step delay [sec]
|
||||
False, # True = print verbose output
|
||||
.05) # initial delay [sec]
|
||||
GPIO.output(enableRight, GPIO.HIGH)
|
||||
|
||||
GPIO.cleanup()
|
||||
def shutdown():
|
||||
GPIO.cleanup() # clear GPIO allocations after run
|
||||
|
||||
if __name__ == '__main__':
|
||||
globals()[sys.argv[1]]()
|
||||
globals()[sys.argv[1]]()
|
||||
|
||||
Reference in New Issue
Block a user