Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →Control with fractions of a millimeter precision (like in 3D printers).
Connect driver pins IN1 to IN4 to digital pins (8, 9, 10, 11). The small motor needs a powerful 5V source.
#include <Stepper.h>
const int stepsPerRevolution = 2048;
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
void setup() {
myStepper.setSpeed(10);
}
void loop() {
myStepper.step(stepsPerRevolution); // دورة كاملة
delay(1000);
myStepper.step(-stepsPerRevolution); // عكس الدوران
delay(1000);
}The pin order for the 28BYJ-48 in the Stepper() function is NOT sequential. You must write 8, 10, 9, 11 for smooth rotation — otherwise the motor will vibrate and not rotate.