├── .gitattributes ├── .gitignore ├── Documentation └── Configurations.ods ├── Firmware ├── hw20ExampleCode │ └── hw20ExampleCode.ino ├── hw20TimerOneExample │ └── hw20TimerOneExample.ino └── hw20ctrlLEDtest │ └── hw20ctrlLEDtest.ino ├── Hardware ├── SparkFun_Ardumoto.brd └── SparkFun_Ardumoto.sch ├── Production └── 13595-SparkFun_Ardumoto-panel.v20.brd └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## SparkFun Useful stuff 3 | ################# 4 | 5 | ## AVR Development 6 | *.eep 7 | *.elf 8 | *.lst 9 | *.lss 10 | *.sym 11 | *.d 12 | *.o 13 | *.srec 14 | *.map 15 | 16 | ## Notepad++ backup files 17 | *.bak 18 | 19 | ## BOM files 20 | *bom* 21 | 22 | ################# 23 | ## Eclipse 24 | ################# 25 | 26 | *.pydevproject 27 | .project 28 | .metadata 29 | bin/ 30 | tmp/ 31 | *.tmp 32 | *.bak 33 | *.swp 34 | *~.nib 35 | local.properties 36 | .classpath 37 | .settings/ 38 | .loadpath 39 | 40 | # External tool builders 41 | .externalToolBuilders/ 42 | 43 | # Locally stored "Eclipse launch configurations" 44 | *.launch 45 | 46 | # CDT-specific 47 | .cproject 48 | 49 | # PDT-specific 50 | .buildpath 51 | 52 | 53 | ############# 54 | ## Eagle 55 | ############# 56 | 57 | # Ignore the board and schematic backup files 58 | *.b#? 59 | *.s#? 60 | 61 | 62 | ################# 63 | ## Visual Studio 64 | ################# 65 | 66 | ## Ignore Visual Studio temporary files, build results, and 67 | ## files generated by popular Visual Studio add-ons. 68 | 69 | # User-specific files 70 | *.suo 71 | *.user 72 | *.sln.docstates 73 | 74 | # Build results 75 | [Dd]ebug/ 76 | [Rr]elease/ 77 | *_i.c 78 | *_p.c 79 | *.ilk 80 | *.meta 81 | *.obj 82 | *.pch 83 | *.pdb 84 | *.pgc 85 | *.pgd 86 | *.rsp 87 | *.sbr 88 | *.tlb 89 | *.tli 90 | *.tlh 91 | *.tmp 92 | *.vspscc 93 | .builds 94 | *.dotCover 95 | 96 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 97 | #packages/ 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opensdf 104 | *.sdf 105 | 106 | # Visual Studio profiler 107 | *.psess 108 | *.vsp 109 | 110 | # ReSharper is a .NET coding add-in 111 | _ReSharper* 112 | 113 | # Installshield output folder 114 | [Ee]xpress 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish 128 | 129 | # Others 130 | [Bb]in 131 | [Oo]bj 132 | sql 133 | TestResults 134 | *.Cache 135 | ClientBin 136 | stylecop.* 137 | ~$* 138 | *.dbmdl 139 | Generated_Code #added for RIA/Silverlight projects 140 | 141 | # Backup & report files from converting an old project file to a newer 142 | # Visual Studio version. Backup files are not needed, because we have git ;-) 143 | _UpgradeReport_Files/ 144 | Backup*/ 145 | UpgradeLog*.XML 146 | 147 | 148 | ############ 149 | ## Windows 150 | ############ 151 | 152 | # Windows image file caches 153 | Thumbs.db 154 | 155 | # Folder config file 156 | Desktop.ini 157 | 158 | 159 | ############# 160 | ## Python 161 | ############# 162 | 163 | *.py[co] 164 | 165 | # Packages 166 | *.egg 167 | *.egg-info 168 | dist 169 | build 170 | eggs 171 | parts 172 | bin 173 | var 174 | sdist 175 | develop-eggs 176 | .installed.cfg 177 | 178 | # Installer logs 179 | pip-log.txt 180 | 181 | # Unit test / coverage reports 182 | .coverage 183 | .tox 184 | 185 | #Translations 186 | *.mo 187 | 188 | #Mr Developer 189 | .mr.developer.cfg 190 | 191 | # Mac crap 192 | .DS_Store 193 | -------------------------------------------------------------------------------- /Documentation/Configurations.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/Ardumoto-Motor_Driver_Shield/0b50305e0bec9645f6f2dd603dead7cb72896d73/Documentation/Configurations.ods -------------------------------------------------------------------------------- /Firmware/hw20ExampleCode/hw20ExampleCode.ino: -------------------------------------------------------------------------------- 1 | /* Ardumoto Example Sketch 2 | by: Jim Lindblom 3 | date: November 8, 2013 4 | license: Public domain. Please use, reuse, and modify this 5 | sketch! 6 | 7 | Adapted to v20 hardware by: Marshall Taylor 8 | date: March 31, 2017 9 | 10 | Three useful functions are defined: 11 | setupArdumoto() -- Setup the Ardumoto Shield pins 12 | driveArdumoto([motor], [direction], [speed]) -- Drive [motor] 13 | (0 for A, 1 for B) in [direction] (0 or 1) at a [speed] 14 | between 0 and 255. It will spin until told to stop. 15 | stopArdumoto([motor]) -- Stop driving [motor] (0 or 1). 16 | 17 | setupArdumoto() is called in the setup(). 18 | The loop() demonstrates use of the motor driving functions. 19 | */ 20 | 21 | // Clockwise and counter-clockwise definitions. 22 | // Depending on how you wired your motors, you may need to swap. 23 | #define FORWARD 0 24 | #define REVERSE 1 25 | 26 | // Motor definitions to make life easier: 27 | #define MOTOR_A 0 28 | #define MOTOR_B 1 29 | 30 | // Pin Assignments // 31 | //Default pins: 32 | #define DIRA 2 // Direction control for motor A 33 | #define PWMA 3 // PWM control (speed) for motor A 34 | #define DIRB 4 // Direction control for motor B 35 | #define PWMB 11 // PWM control (speed) for motor B 36 | 37 | ////Alternate pins: 38 | //#define DIRA 8 // Direction control for motor A 39 | //#define PWMA 9 // PWM control (speed) for motor A 40 | //#define DIRB 7 // Direction control for motor B 41 | //#define PWMB 10 // PWM control (speed) for motor B 42 | 43 | 44 | void setup() 45 | { 46 | setupArdumoto(); // Set all pins as outputs 47 | } 48 | 49 | void loop() 50 | { 51 | // Drive motor A (and only motor A) at various speeds, then stop. 52 | driveArdumoto(MOTOR_A, REVERSE, 255); // Set motor A to REVERSE at max 53 | delay(1000); // Motor A will spin as set for 1 second 54 | driveArdumoto(MOTOR_A, FORWARD, 127); // Set motor A to FORWARD at half 55 | delay(1000); // Motor A will keep trucking for 1 second 56 | stopArdumoto(MOTOR_A); // STOP motor A 57 | 58 | // Drive motor B (and only motor B) at various speeds, then stop. 59 | driveArdumoto(MOTOR_B, REVERSE, 255); // Set motor B to REVERSE at max 60 | delay(1000); // Motor B will spin as set for 1 second 61 | driveArdumoto(MOTOR_B, FORWARD, 127); // Set motor B to FORWARD at half 62 | delay(1000); // Motor B will keep trucking for 1 second 63 | stopArdumoto(MOTOR_B); // STOP motor B 64 | 65 | // Drive both 66 | driveArdumoto(MOTOR_A, FORWARD, 255); // Motor A at max speed. 67 | driveArdumoto(MOTOR_B, FORWARD, 255); // Motor B at max speed. 68 | delay(1000); // Drive forward for a second 69 | // Now go backwards at half that speed: 70 | driveArdumoto(MOTOR_A, REVERSE, 127); // Motor A at max speed. 71 | driveArdumoto(MOTOR_B, REVERSE, 127); // Motor B at max speed. 72 | delay(1000); // Drive forward for a second 73 | 74 | // Now spin in place! 75 | driveArdumoto(MOTOR_A, FORWARD, 255); // Motor A at max speed. 76 | driveArdumoto(MOTOR_B, REVERSE, 255); // Motor B at max speed. 77 | delay(2000); // Drive forward for a second 78 | stopArdumoto(MOTOR_A); // STOP motor A 79 | stopArdumoto(MOTOR_B); // STOP motor B 80 | 81 | } 82 | 83 | // driveArdumoto drives 'motor' in 'dir' direction at 'spd' speed 84 | void driveArdumoto(byte motor, byte dir, byte spd) 85 | { 86 | if (motor == MOTOR_A) 87 | { 88 | digitalWrite(DIRA, dir); 89 | analogWrite(PWMA, spd); 90 | } 91 | else if (motor == MOTOR_B) 92 | { 93 | digitalWrite(DIRB, dir); 94 | analogWrite(PWMB, spd); 95 | } 96 | } 97 | 98 | // stopArdumoto makes a motor stop 99 | void stopArdumoto(byte motor) 100 | { 101 | driveArdumoto(motor, 0, 0); 102 | } 103 | 104 | // setupArdumoto initialize all pins 105 | void setupArdumoto() 106 | { 107 | // All pins should be setup as outputs: 108 | pinMode(PWMA, OUTPUT); 109 | pinMode(PWMB, OUTPUT); 110 | pinMode(DIRA, OUTPUT); 111 | pinMode(DIRB, OUTPUT); 112 | 113 | // Initialize all pins as low: 114 | digitalWrite(PWMA, LOW); 115 | digitalWrite(PWMB, LOW); 116 | digitalWrite(DIRA, LOW); 117 | digitalWrite(DIRB, LOW); 118 | } 119 | -------------------------------------------------------------------------------- /Firmware/hw20TimerOneExample/hw20TimerOneExample.ino: -------------------------------------------------------------------------------- 1 | //This sketch walks through various drive states. 2 | //Use the serial terminal to advance states. Enter some serial data and press return. 3 | //The sketch only check for the existance of data, not what it is. 4 | // 5 | //The Ardumoto must have all pins set to alternate, timer1 only works on 6 | //pins 9 and 10. 7 | // 8 | //Marshall Taylor 9 | //March 3, 2017 10 | 11 | #include "TimerOne.h" 12 | 13 | // Clockwise and counter-clockwise definitions. 14 | // Depending on how you wired your motors, you may need to swap. 15 | #define FORWARD 0 16 | #define REVERSE 1 17 | 18 | // Motor definitions to make life easier: 19 | #define MOTOR_A 0 20 | #define MOTOR_B 1 21 | 22 | // Pin Assignments // 23 | // Timer1 connects only to PWM pins 9 and 10. 24 | 25 | //Alternate pins: 26 | #define DIRA 8 // Direction control for motor A 27 | #define PWMA 9 // PWM control (speed) for motor A 28 | #define DIRB 7 // Direction control for motor B 29 | #define PWMB 10 // PWM control (speed) for motor B 30 | 31 | void setup() 32 | { 33 | Serial.begin(115200); 34 | setupArdumoto(); // Set all pins as outputs 35 | } 36 | 37 | void loop() 38 | { 39 | int loopRunning = 1; 40 | int counter = 0; 41 | int state = 0; 42 | while( loopRunning == 1 ) 43 | { 44 | //ramp up 45 | switch( state ) 46 | { 47 | case 0: 48 | driveArdumoto(MOTOR_A, FORWARD, counter); 49 | driveArdumoto(MOTOR_B, FORWARD, counter); 50 | counter++; 51 | if( counter == 256 ) 52 | { 53 | counter = 255; 54 | state = 1; 55 | } 56 | break; 57 | case 1: 58 | driveArdumoto(MOTOR_A, FORWARD, counter); 59 | driveArdumoto(MOTOR_B, FORWARD, counter); 60 | counter--; 61 | if( counter == 1 ) 62 | { 63 | counter = 0; 64 | state = 0; 65 | } 66 | break; 67 | case 2: 68 | break; 69 | default: 70 | break; 71 | } 72 | delay(3); 73 | if( Serial.available() ) 74 | { 75 | loopRunning = 0; 76 | } 77 | } 78 | waitForInput(); 79 | 80 | // Now spin both! 81 | driveArdumoto(MOTOR_A, FORWARD, 255); // Motor A at max speed. 82 | driveArdumoto(MOTOR_B, FORWARD, 255); // Motor B at max speed. 83 | waitForInput(); 84 | 85 | // Now go backwards at half that speed: 86 | driveArdumoto(MOTOR_A, REVERSE, 127); // Motor A at max speed. 87 | driveArdumoto(MOTOR_B, REVERSE, 127); // Motor B at max speed. 88 | waitForInput(); 89 | 90 | stopArdumoto(MOTOR_A); // STOP motor A 91 | stopArdumoto(MOTOR_B); // STOP motor A 92 | waitForInput(); 93 | } 94 | 95 | // driveArdumoto drives 'motor' in 'dir' direction at 'spd' speed 96 | void driveArdumoto(byte motor, byte dir, byte spd) 97 | { 98 | if (motor == MOTOR_A) 99 | { 100 | digitalWrite(DIRA, dir); 101 | //analogWrite(PWMA, spd); 102 | Timer1.pwm(PWMA, spd << 2); 103 | } 104 | else if (motor == MOTOR_B) 105 | { 106 | digitalWrite(DIRB, dir); 107 | //analogWrite(PWMB, spd); 108 | Timer1.pwm(PWMB, spd << 2); 109 | } 110 | } 111 | 112 | // stopArdumoto makes a motor stop 113 | void stopArdumoto(byte motor) 114 | { 115 | driveArdumoto(motor, 0, 0); 116 | } 117 | 118 | // setupArdumoto initialize all pins 119 | void setupArdumoto() 120 | { 121 | // All pins should be setup as outputs: 122 | pinMode(PWMA, OUTPUT); 123 | pinMode(PWMB, OUTPUT); 124 | pinMode(DIRA, OUTPUT); 125 | pinMode(DIRB, OUTPUT); 126 | 127 | // Initialize all pins as low: 128 | digitalWrite(PWMA, LOW); 129 | digitalWrite(PWMB, LOW); 130 | digitalWrite(DIRA, LOW); 131 | digitalWrite(DIRB, LOW); 132 | 133 | Timer1.initialize(200); // initialize timer1 134 | 135 | } 136 | 137 | void waitForInput( void ) 138 | { 139 | while( Serial.available() == 0 ) 140 | { 141 | delay(1); 142 | } 143 | while( Serial.available() == 1 ) 144 | { 145 | Serial.read(); 146 | delay(1); 147 | } 148 | } -------------------------------------------------------------------------------- /Firmware/hw20ctrlLEDtest/hw20ctrlLEDtest.ino: -------------------------------------------------------------------------------- 1 | //Ardumoto test sketch 2 | 3 | //This sketch tests control and status LEDs 4 | 5 | //The sketch walks through both default and alternate pins. It sends 6 | //serial data indicating which LEDs should be lit for a configuration, 7 | //then waits for user input before continuing. 8 | 9 | //Please do not connect any motors to the driver. 10 | 11 | //(This is also the source location for pin defines) 12 | 13 | //// Pin Assignments // 14 | ////Default pins: 15 | //#define DIRA 2 // Direction control for motor A 16 | //#define PWMA 3 // PWM control (speed) for motor A 17 | //#define DIRB 4 // Direction control for motor B 18 | //#define PWMB 11 // PWM control (speed) for motor B 19 | // 20 | //////Alternate pins: 21 | ////#define DIRA 8 // Direction control for motor A 22 | ////#define PWMA 9 // PWM control (speed) for motor A 23 | ////#define DIRB 7 // Direction control for motor B 24 | ////#define PWMB 10 // PWM control (speed) for motor B 25 | 26 | //Test specific namings: 27 | #define DIRA 2 // Direction control for motor A 28 | #define PWMA 3 // PWM control (speed) for motor A 29 | #define DIRB 4 // Direction control for motor B 30 | #define PWMB 11 // PWM control (speed) for motor B 31 | #define ALT_DIRA 8 // Direction control for motor A 32 | #define ALT_PWMA 9 // PWM control (speed) for motor A 33 | #define ALT_DIRB 7 // Direction control for motor B 34 | #define ALT_PWMB 10 // PWM control (speed) for motor B 35 | 36 | 37 | 38 | void setup() 39 | { 40 | Serial.begin(115200); 41 | } 42 | 43 | void loop() 44 | { 45 | //Set up for standard 46 | pinMode(PWMA, OUTPUT); 47 | pinMode(PWMB, OUTPUT); 48 | pinMode(DIRA, OUTPUT); 49 | pinMode(DIRB, OUTPUT); 50 | digitalWrite(PWMA, LOW); 51 | digitalWrite(PWMB, LOW); 52 | digitalWrite(DIRA, LOW); 53 | digitalWrite(DIRB, LOW); 54 | Serial.println("Testing default mode:"); 55 | 56 | //Display PWMA 57 | Serial.println("PWMA should be lit, Drive A should be orange"); 58 | digitalWrite(PWMA, HIGH); 59 | waitForInput(); 60 | 61 | //Display PWMA and DIRA 62 | Serial.println("PWMA and DIRA should be lit, Drive A should be blue"); 63 | digitalWrite(DIRA, HIGH); 64 | waitForInput(); 65 | digitalWrite(PWMA, LOW); 66 | digitalWrite(DIRA, LOW); 67 | 68 | //Display PWMB 69 | Serial.println("PWMB should be lit, Drive B should be orange"); 70 | digitalWrite(PWMB, HIGH); 71 | waitForInput(); 72 | 73 | //Display PWMB and DIRA 74 | Serial.println("PWMB and DIRB should be lit, Drive B should be blue"); 75 | digitalWrite(DIRB, HIGH); 76 | waitForInput(); 77 | digitalWrite(PWMB, LOW); 78 | digitalWrite(DIRB, LOW); 79 | 80 | pinMode(PWMA, INPUT); 81 | pinMode(PWMB, INPUT); 82 | pinMode(DIRA, INPUT); 83 | pinMode(DIRB, INPUT); 84 | 85 | //Set up for standard 86 | pinMode(ALT_PWMA, OUTPUT); 87 | pinMode(ALT_PWMB, OUTPUT); 88 | pinMode(ALT_DIRA, OUTPUT); 89 | pinMode(ALT_DIRB, OUTPUT); 90 | digitalWrite(ALT_PWMA, LOW); 91 | digitalWrite(ALT_PWMB, LOW); 92 | digitalWrite(ALT_DIRA, LOW); 93 | digitalWrite(ALT_DIRB, LOW); 94 | 95 | Serial.println("Testing alternate mode:"); 96 | 97 | //Display PWMA 98 | Serial.println("PWMA should be lit, Drive A should be orange"); 99 | digitalWrite(ALT_PWMA, HIGH); 100 | waitForInput(); 101 | 102 | //Display PWMA and DIRA 103 | Serial.println("PWMA and DIRA should be lit, Drive A should be blue"); 104 | digitalWrite(ALT_DIRA, HIGH); 105 | waitForInput(); 106 | digitalWrite(ALT_PWMA, LOW); 107 | digitalWrite(ALT_DIRA, LOW); 108 | 109 | //Display PWMB 110 | Serial.println("PWMB should be lit, Drive B should be orange"); 111 | digitalWrite(ALT_PWMB, HIGH); 112 | waitForInput(); 113 | 114 | //Display PWMB and DIRA 115 | Serial.println("PWMB and DIRB should be lit, Drive B should be blue"); 116 | digitalWrite(ALT_DIRB, HIGH); 117 | waitForInput(); 118 | digitalWrite(ALT_PWMB, LOW); 119 | digitalWrite(ALT_DIRB, LOW); 120 | 121 | pinMode(ALT_PWMA, INPUT); 122 | pinMode(ALT_PWMB, INPUT); 123 | pinMode(ALT_DIRA, INPUT); 124 | pinMode(ALT_DIRB, INPUT); 125 | 126 | 127 | } 128 | 129 | 130 | void waitForInput( void ) 131 | { 132 | while( Serial.available() == 0 ) 133 | { 134 | delay(1); 135 | } 136 | while( Serial.available() == 1 ) 137 | { 138 | Serial.read(); 139 | delay(1); 140 | } 141 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SparkFun Ardumoto - Motor Driver Shield 2 | ======================================= 3 | 4 | ![SparkFun Ardumoto - Motor Driver Shield](https://cdn.sparkfun.com//assets/parts/1/2/0/2/5/14129-01.jpg) 5 | 6 | [*SparkFun Ardumoto - Motor Driver Shield (DEV-14129)*](https://www.sparkfun.com/products/14129) 7 | 8 | This is a motor shield for Arduino that will control two DC motors. 9 | Based on the L298 H-bridge, the SparkFun Ardumoto can drive up to 2 amps per channel. 10 | 11 | Repository Contents 12 | ------------------- 13 | * **/Firmware** - Example Arduino sketch 14 | * **/Hardware** - All Eagle design files (.brd, .sch) 15 | 16 | Documentation 17 | -------------- 18 | * [Hookup Guide](https://learn.sparkfun.com/tutorials/ardumoto-kit-hookup-guide) 19 | 20 | Version History 21 | --------------- 22 | 23 | * [HW_1.4_FW_1.0](https://github.com/sparkfun/Ardumoto-Motor_Driver_Shield/tree/HW_1.4_FW_1.0) - Version 1.4 24 | * [V_2.0.0](https://github.com/sparkfun/Ardumoto-Motor_Driver_Shield/tree/V_2.0.0) - Initial build release 25 | * [V_2.0.1](https://github.com/sparkfun/Ardumoto-Motor_Driver_Shield/tree/V_2.0.1) - Public release 26 | 27 | License Information 28 | ------------------- 29 | The hardware is released under [Creative Commons ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). 30 | The code is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! 31 | 32 | Distributed as-is; no warranty is given. 33 | --------------------------------------------------------------------------------