Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
* This example shows how to control MDDS60 in Serial Simplified with Arduino.
* Set MDDS60 input mode to 0b11001100
*
* Serial data (8-bits): 0bMDSSSSSS
* M: Select motor, 0 for left, 1 for right.
* D: Direction, 0 for CW, 1 for CCW.
* SSSSSS: Motor speed.
*
* Example: Value in Decimal
* 0 or 64 - motor LEFT stop.
* 63 - motor LEFT full forward.
* 127 - motor LEFT full reverse.
* 128 or 192 - motor RIGHT stop.
* 191 - motor RIGHT full forward.
* 255 - motor RIGHT full reverse.
*
* Reference Tutorial:
* - Let's Arduino Control Your SmartDriveDuo-60
*
* Related Products:
* - SmartDriveDuo-60: http://www.cytron.com.my/P-MDDS60
* - CT UNO: http://www.cytron.com.my/p-ct-uno
* - DC Brush Motors: http://www.cytron.com.my/c-84-dc-motor
* - LiPo Battery: http://www.cytron.com.my/c-87-power/c-97-lipo-rechargeable-battery-and-charger
*
* URL: http://www.cytron.com.my
*/
#include <SoftwareSerial.h>
SoftwareSerial MDDS60Serial(2, 3); // RX (not use), TX
void setup()
{
MDDS60Serial.begin(9600); // Initialize serial
delay(5000); // Delay for 5 seconds.
}
void loop()
{
MDDS60Serial.write(32); // Motor left start moving with half speed for 2s.
delay(2000);
MDDS60Serial.write(32); // Motor left move to another direction with half speed for 2s.
delay(2000);
MDDS60Serial.write((byte)0); // Motor left stop.
delay(1000); // Delay for 1s.
MDDS60Serial.write(160); // Motor right start moving with half speed for 2s.
delay(2000);
MDDS60Serial.write(224); // Motor right move to another direction with half speed for 2s.
delay(2000);
MDDS60Serial.write(128); // Motor right stop.
delay(1000); // Delay for 1s.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment