move the mbot forward and backward

This commit is contained in:
Gabri6 2023-04-24 11:01:39 +02:00
parent 229776a76c
commit 25c8ad4ebc
1 changed files with 12 additions and 1 deletions

View File

@ -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);
}