Last active
August 29, 2015 13:56
-
-
Save treeherder/9317034 to your computer and use it in GitHub Desktop.
control l298d breakout module
This file contains hidden or 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
| typedef struct return_data current; | |
| struct return_data | |
| { | |
| uint32_t c_1; //current one | |
| uint32_t c_2; //current two | |
| //quadrature encoder data can come in here | |
| //accelerometer data? | |
| }; | |
| uint32_t forward(return_data *curr) | |
| { | |
| uint32_t _c1; | |
| uint32_t _c2; | |
| _c1 = 1; | |
| _c2 = 1; | |
| digitalWrite(M1A,HIGH); //right wheel channel 1 | |
| digitalWrite(M1B,HIGH); //right wheel channel 2 | |
| digitalWrite(EN1A,HIGH); //right enable channel 1 | |
| digitalWrite(EN1B,HIGH); //right enable channel 2 | |
| digitalWrite(M2A,LOW); //left wheel channel 1 | |
| digitalWrite(M2B,LOW); //left wheel channel 2 | |
| digitalWrite(EN2A,HIGH); //left enable channel 1 | |
| digitalWrite(EN2B,HIGH); //left enable channel 2 | |
| curr -> analogRead(C1) = _c1; | |
| curr -> analogRead(C2) = _c2; // check current for both wheels | |
| return (0); | |
| } |
We'll need to add this on line 69 -- could be crucial
69 + digitalWrite(M1A,LOW); //right wheel channel 1
70 digitalWrite(M1B,LOW); //right wheel channel 2
71 digitalWrite(EN1A,HIGH);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code looks great!