hello_mbot_motor
Hello mBot Motor
Dieses Arduino-Programm steuert die Motoren des mBot und lässt ihn sich abwechselnd in entgegengesetzte Richtungen drehen. Die Motoren am Port M1 und M2 laufen mit einer Geschwindigkeit von ±100 (maximaler Wert: ±255). Nach 500 ms wechselt die Drehrichtung, dann stoppt der mBot für 1 Sekunde, bevor der Zyklus erneut beginnt.
Quellcode (engl. Sourcecode)
Listing 1:MinimalesProgramm.ino
#include <MeMCore.h> MeDCMotor motor1(M1); MeDCMotor motor2(M2); void setup(){} void loop() { //motor.run() maximum speed is 255 to -255, 0 is stop motor1.run(-100); //Motor1 motor2.run(100); //Motor2 delay(500); motor1.run(100); //Motor1 motor2.run(-100); //Motor2 delay(500); motor1.stop(); //Stop Motor1 motor2.stop(); //Stop Motor1 delay(1000); }
Erklärungen zum Quellcode
hello_mbot_motor.txt · Zuletzt geändert: 2025/02/03 15:08 von torsten.roehl