Created
January 25, 2017 06:57
-
-
Save IdrisCytron/412ede87ed0afec2ff944bb763fb8e27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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