move the mbot forward and backward
This commit is contained in:
parent
229776a76c
commit
25c8ad4ebc
|
|
@ -1,12 +1,18 @@
|
|||
#include <MeMCore.h
|
||||
#include <MeMCore.h>
|
||||
|
||||
MeDCMotor leftRotor(9);
|
||||
MeDCMotor rightRotor(10);
|
||||
float lSpeed;
|
||||
float rSpeed;
|
||||
float duration;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
leftRotor.run(0);
|
||||
rightRotor.run(0);
|
||||
lSpeed = 100.0;
|
||||
rSpeed = -100.0;
|
||||
duration = 1000.0;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -17,4 +23,9 @@ void loop() {
|
|||
delay(duration);
|
||||
leftRotor.stop();
|
||||
rightRotor.stop();
|
||||
delay(duration);
|
||||
leftRotor.run(0-lSpeed);
|
||||
rightRotor.run(0-rSpeed);
|
||||
delay(duration);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue