Last active
January 25, 2017 03:44
-
-
Save IdrisCytron/b0e25ff65881c123902bcc2d6bfaa153 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 PWM mode with Arduino. | |
* Set MDDS60 input mode to 0b10110100 | |
* | |
* Reference Tutorial: | |
* - Let's Arduino Controlling 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 | |
*/ | |
int DIG1 = 7; // Arduino pin 7 is connected to MDDS60 pin DIG1. | |
int DIG2 = 4; // Arduino pin 4 is connected to MDDS60 pin DIG2. | |
int AN1 = 6; // Arduino pin 6 is connected to MDDS60 pin AN1. | |
int AN2 = 5; // Arduino pin 5 is connected to MDDS60 pin AN2. | |
void setup() | |
{ | |
pinMode(DIG1, OUTPUT); // Set Arduino pin 7 (DIG1) as output. | |
pinMode(DIG2, OUTPUT); // Set Arduino pin 4 (DIG2) as output. | |
pinMode(AN1, OUTPUT); // Set Arduino pin 6 (AN1) as output. | |
pinMode(AN2, OUTPUT); // Set Arduino pin 5 (AN2) as output. | |
delay(5000); // Delay for 5 seconds. | |
} | |
void loop() | |
{ | |
// Controlling motor 1. | |
analogWrite(AN1, 100); // Set motor 1 speed less than half. Max is 255. | |
digitalWrite(DIG1, LOW); // Motor 1 start moving for 2s. | |
delay(2000); | |
digitalWrite(DIG1, HIGH); // Motor 1 move to another direction for 2s. | |
delay(2000); | |
analogWrite(AN1, 0); // Stop motor 1. | |
delay(1000); // Delay for 1s | |
// Controlling motor 2. | |
analogWrite(AN2, 100); // Set motor 2 speed less than half. Max is 255. | |
digitalWrite(DIG2, LOW); // Motor 1 start moving for 2s. | |
delay(2000); | |
digitalWrite(DIG2, HIGH); // Motor 1 move to another direction for 2s. | |
delay(2000); | |
analogWrite(AN2, 0); // Stop motor 2. | |
delay(1000); // Delay for 1s | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment