Devices & Components
Arduino Uno Rev3
Pushbutton Switch, Momentary
MD10C-R3 Motor Controller Board
Hardware & Tools
Hot glue gun (generic)
Soldering iron (generic)
Software & Tools
Arduino IDE
Project description
Code
Motor Control Code
arduino
Adjust the timing of the motors via the "int delaymills_ = ___;" lines.
1//define pin name 2#define dir 1 // Direction 3#define pwrA 2 // Power for Motor A 4#define pwrB 4 // Power for Motor B 5#define pwrC 7 // Power for Motor C 6 7//constants won't change 8const int buttonPin = 8; // the number of the pushbutton pin 9 10// variables will change 11int buttonState = 0; // variable for reading the pushbutton status 12int pwrAState = LOW; 13int pwrBState = LOW; 14int pwrcState = LOW; 15int delaymillsA = 400; 16int delaymillsAr = 400; // Return delay 17int delaymillsB = 400; 18int delaymillsBr = 400; // Return delay 19int delaymillsC = 500; 20int delaymillsCr = 500; // Return delay 21int delaymillsD = 100; 22 23void setup() { 24 // initialize the pwr and dir pins as outputs: 25 pinMode(pwrA,OUTPUT); 26 pinMode(pwrB,OUTPUT); 27 pinMode(pwrC,OUTPUT); 28 pinMode(dir,OUTPUT); 29 30 // initialize the pushbutton pin as an input: 31 pinMode(buttonPin, INPUT); 32} 33void loop() { 34 // read the state of the pushbutton value: 35 buttonState = digitalRead(buttonPin); 36 37// check if the pushbutton is pressed. If it is, the buttonState is HIGH: 38 if (buttonState == HIGH) { 39digitalWrite(pwrA,HIGH); 40digitalWrite(dir,HIGH); // set DIR pin HIGH or LOW 41delay(delaymillsA); 42digitalWrite(dir,LOW); // set DIR pin HIGH or LOW 43delay(delaymillsAr); 44digitalWrite(pwrA,LOW); 45delay(delaymillsD); 46digitalWrite(pwrB,HIGH); 47digitalWrite(dir,HIGH); // set DIR pin HIGH or LOW 48delay(delaymillsB); 49digitalWrite(dir,LOW); // set DIR pin HIGH or LOW 50delay(delaymillsBr); 51digitalWrite(pwrB,LOW); 52delay(delaymillsD); 53digitalWrite(pwrC,HIGH); 54digitalWrite(dir,HIGH); // set DIR pin HIGH or LOW 55delay(delaymillsC); 56digitalWrite(dir,LOW); // set DIR pin HIGH or LOW 57delay(delaymillsCr); 58digitalWrite(pwrC,LOW); 59delay(delaymillsD); 60 } else { 61 // turn LED off: 62 digitalWrite(pwrA, LOW); 63 digitalWrite(pwrB, LOW); 64 digitalWrite(pwrC, LOW); 65 } 66}
Motor Control Code
arduino
Adjust the timing of the motors via the "int delaymills_ = ___;" lines.
1//define pin name 2#define dir 1 // Direction 3#define pwrA 2 // Power for Motor A 4#define pwrB 4 // Power for Motor B 5#define pwrC 7 // Power for Motor C 6 7//constants won't change 8const int buttonPin = 8; // the number of the pushbutton pin 9 10// variables will change 11int buttonState = 0; // variable for reading the pushbutton status 12int pwrAState = LOW; 13int pwrBState = LOW; 14int pwrcState = LOW; 15int delaymillsA = 400; 16int delaymillsAr = 400; // Return delay 17int delaymillsB = 400; 18int delaymillsBr = 400; // Return delay 19int delaymillsC = 500; 20int delaymillsCr = 500; // Return delay 21int delaymillsD = 100; 22 23void setup() { 24 // initialize the pwr and dir pins as outputs: 25 pinMode(pwrA,OUTPUT); 26 pinMode(pwrB,OUTPUT); 27 pinMode(pwrC,OUTPUT); 28 pinMode(dir,OUTPUT); 29 30 // initialize the pushbutton pin as an input: 31 pinMode(buttonPin, INPUT); 32} 33void loop() { 34 // read the state of the pushbutton value: 35 buttonState = digitalRead(buttonPin); 36 37// check if the pushbutton is pressed. If it is, the buttonState is HIGH: 38 if (buttonState == HIGH) { 39digitalWrite(pwrA,HIGH); 40digitalWrite(dir,HIGH); // set DIR pin HIGH or LOW 41delay(delaymillsA); 42digitalWrite(dir,LOW); // set DIR pin HIGH or LOW 43delay(delaymillsAr); 44digitalWrite(pwrA,LOW); 45delay(delaymillsD); 46digitalWrite(pwrB,HIGH); 47digitalWrite(dir,HIGH); // set DIR pin HIGH or LOW 48delay(delaymillsB); 49digitalWrite(dir,LOW); // set DIR pin HIGH or LOW 50delay(delaymillsBr); 51digitalWrite(pwrB,LOW); 52delay(delaymillsD); 53digitalWrite(pwrC,HIGH); 54digitalWrite(dir,HIGH); // set DIR pin HIGH or LOW 55delay(delaymillsC); 56digitalWrite(dir,LOW); // set DIR pin HIGH or LOW 57delay(delaymillsCr); 58digitalWrite(pwrC,LOW); 59delay(delaymillsD); 60 } else { 61 // turn LED off: 62 digitalWrite(pwrA, LOW); 63 digitalWrite(pwrB, LOW); 64 digitalWrite(pwrC, LOW); 65 } 66}
Downloadable files
Circuit Diagram
Connect wires as shown. You can tie all of the 12V power supplies to the same power rail on the other side of the breadboard.
Circuit Diagram
Documentation
Motor Paddle
3D print STL for 37mm Drive Shaft and 0.1875" foam board.
Motor Paddle
Motor Clamp
3D print STL for DC Motor - use zip ties to clamp motor.
Motor Clamp
Motor Coupler
3D print STL for 37mm Drive Shaft and .25inch wooden dowel.
Motor Coupler
Motor Coupler
3D print STL for 37mm Drive Shaft and .25inch wooden dowel.
Motor Coupler
Motor Paddle
3D print STL for 37mm Drive Shaft and 0.1875" foam board.
Motor Paddle
Motor Clamp
3D print STL for DC Motor - use zip ties to clamp motor.
Motor Clamp
Comments
Only logged in users can leave comments