Last active
December 17, 2015 11:28
-
-
Save ferclaverino/5602006 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
#include <DCMotor.h> | |
DCMotor motor0(M0_EN, M0_D0, M0_D1); | |
DCMotor motor1(M1_EN, M1_D0, M1_D1); | |
void setup() | |
{ | |
} | |
void loop() | |
{ | |
if(analogRead(1)>70 && analogRead(2)>70) | |
{ | |
motor0.setSpeed(30); | |
motor1.setSpeed(-30); | |
} | |
else if(analogRead(1)>80) | |
{ | |
motor0.setSpeed(20); | |
motor1.setSpeed(-70); | |
} | |
else if(analogRead(2)>80) | |
{ | |
motor0.setSpeed(70); | |
motor1.setSpeed(-20); | |
} | |
else | |
{ | |
motor0.setSpeed(0); | |
motor1.setSpeed(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment