Created
November 15, 2012 22:33
-
-
Save johndavid400/4081893 to your computer and use it in GitHub Desktop.
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
| void loop(){ | |
| m1_drive(50); | |
| m2_drive(-50); | |
| } | |
| void m1_drive(int speed){ | |
| int val = map(speed, -100, 100, 1, 127); | |
| if (val > 127){ | |
| val = 127; | |
| } | |
| else if (val < 1){ | |
| val = 1; | |
| } | |
| else{ | |
| val = 64; | |
| } | |
| Serial.write(speed) | |
| } | |
| void m2_drive(int speed){ | |
| int val = map(speed, -100, 100, 128, 255); | |
| if (val < 128){ | |
| val = 128; | |
| } | |
| else if (val > 255){ | |
| val = 255; | |
| } | |
| else{ | |
| val = 192; | |
| } | |
| Serial.write(speed) | |
| } | |
| void stop_motors(){ | |
| Serial.write(0) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment