// Stepper motor on Wokwi!
#include <Stepper.h>
#include <LiquidCrystal_I2C.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
// DEFINIÇÕES
#define endereco 0x27 // Endereços comuns: 0x27, 0x3F
#define colunas 16
#define linhas 2
//int stepCount=0;
// INSTANCIANDO OBJETOS
LiquidCrystal_I2C lcd(endereco, colunas, linhas);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(5);
// initialize the serial port:
//Serial.begin(9600);
lcd.init(); // INICIA A COMUNICAÇÃO COM O DISPLAY
lcd.backlight(); // LIGA A ILUMINAÇÃO DO DISPLAY
lcd.clear(); // LIMPA O DISPLAY
}
void loop() {
// Gira 90 graus no sentido horário
//Serial.println("clockwise");
for (int i=0; i<200; i++){
myStepper.step(1);
lcd.clear();
lcd.print(i+1);
}
for (int i=0; i<200; i++){
myStepper.step(-1);
lcd.clear();
lcd.print(i+1);
}
// Gira 90 graus no sentido anti-horário
//Serial.println("clockwise");
// for (int i=0; i<3; i++){
//myStepper.step(-50);
//lcd.clear();
//lcd.print("-50");
//delay(1000);
// }
// step one revolution in the other direction:
// Serial.println("counterclockwise");
// myStepper.step(-stepsPerRevolution);
// delay(500);
}