Skip to content

Instantly share code, notes, and snippets.

@johndavid400
Created November 15, 2012 22:33
Show Gist options
  • Select an option

  • Save johndavid400/4081893 to your computer and use it in GitHub Desktop.

Select an option

Save johndavid400/4081893 to your computer and use it in GitHub Desktop.
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