45 lines
550 B
C++
45 lines
550 B
C++
|
|
#include <MeMCore.h>
|
|
|
|
// The two motor objects
|
|
MeDCMotor motor1(9);
|
|
MeDCMotor motor2(10);
|
|
|
|
uint8_t Lspeed = 100;
|
|
uint8_t Rspeed = 100;
|
|
void setup()
|
|
{
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
|
|
devant();
|
|
delay(1000);
|
|
stop();
|
|
delay(100);
|
|
turnleft();
|
|
delay(1000);
|
|
|
|
}
|
|
void turnright(){
|
|
motor1.run(Lspeed);
|
|
motor2.run(Rspeed);
|
|
}
|
|
void turnleft(){
|
|
motor1.run(-Lspeed);
|
|
motor2.run(-Rspeed);
|
|
}
|
|
void devant(){
|
|
motor1.run(-Lspeed);
|
|
motor2.run(Rspeed);
|
|
}
|
|
void derriere(){
|
|
motor1.run(Lspeed);
|
|
motor2.run(-Rspeed);
|
|
}
|
|
void stop(){
|
|
motor1.run(0);
|
|
motor2.run(0);
|
|
}
|