I am a newcomer to Cytron smart driver and need help.
I am using a Mdds30, Adruino uno, Analog Joystick and want to control 2 motors direction and speed, to steer a platform
X axis should control forward and backward rotation on both motors at same time.
Y axis should control the speed of left motor when Joystick is pushed to left from centre and same idea for right motor.
Basically the same idea as driving a wheelchair.
How do I change the code to achieve above functions.
Your help would be very appreciated.
#include <Cytron_SmartDriveDuo.h>
#define IN1 4 // Arduino pin 4 is connected to MDDS30 pin IN1.
#define AN1 5 // Arduino pin 5 is connected to MDDS30 pin AN1.
#define AN2 6 // Arduino pin 6 is connected to MDDS30 pin AN2.
#define IN2 7 // Arduino pin 7 is connected to MDDS30 pin IN2.
Cytron_SmartDriveDuo smartDriveDuo30(PWM_INDEPENDENT, IN1, IN2, AN1, AN2);
char inChar;
signed int speedLeft, speedRight;
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
digitalWrite(13, HIGH);
delay(0); // Delay for 5 seconds.
digitalWrite(13, LOW);
}
void loop()
{
int adc1 = analogRead(A0);
speedRight = map(adc1, 0, 1023, -100, 100);
int adc2 = analogRead(A1);
speedLeft = map(adc2, 0, 1023, -100, 100);
smartDriveDuo30.control(speedLeft, speedRight);
delay(0);
}
I got the switches on the MDDS30 set as following
1-on
2-off
3-on
4-on
5-off
6-off
7-off
8-off
x axis works perfect, push joystick forward both motors run forward and speed can be controlled
push joystick back and both motors run backwards and speed can be controlled
y axis does not work properly. push joystick to left, left motor should run only and speed should be able to be controlled,
left motor works fine, but right motor runs backwards instead being stopped.
same problem with right motor id joystick is pushed to right, right motor runs in reverse instead forward,
opposite direction to the left motor.
Is the problem in the switches or in the code?
I done some similar design with different motor drivers, but this time I need more powerful motors.
the speed of the platform will be 15 ft per minute.
hope some body understands my explanation and has some idea, where I went wrong.