Need Help for Stepper motor control using mouse wheel rotary encoder...

Can anyone help me on my project, i am new in using Arduino and cannot quite figure out how to control the stepper motor using a mouse wheel rotary encoder…

This is my code for the stepper motor using serial control.

#include “BasicStepperDriver.h”

#define MOTOR_STEPS 200
#define DIR 2
#define STEP 7
#define MICROSTEPS 1
BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP);

int led = 13;
int val = 0;

int state = 0;

void setup() {
Serial.begin(9600); // Default communication rate of the Bluetooth module

stepper.setRPM(60);
stepper.disable();

pinMode(led, OUTPUT);

}

void loop() {

stepper.setMicrostep(MICROSTEPS);
val = digitalRead(led);

if (Serial.available()) { // Checks whether data is coming from the serial port
state = Serial.read(); // Reads the data from the serial port
}
if (state == ‘0’) {
Serial.println(“Move 20 DOWN”); // Send back, to the phone, the String “LED: ON”
stepper.rotate(-10);
state = 0;
}
else if (state == ‘1’) {
Serial.println(“Move 20 UP”);
stepper.rotate(10);
state = 0;
}
}

Harimel:
Can anyone help me on my project, i am new in using Arduino and cannot quite figure out how to control the stepper motor using a mouse wheel rotary encoder..

Your code does not seem to make any attempt to read the encoder and you have not provided any information about how you want the encoder movement to relate to the motor movement.

Also, what is "BasicStepperDriver.h"? - post a link to its documentation.

Do you have a link to the documentation for the encoder, or. if it is something you salvaged from a mouse, make a drawing showing how it is connected to the Arduino and post a photo of the drawing.

What type of stepper motor and stepper motor driver are you using? Post a link to the datasheet for the motor.

...R
Stepper Motor Basics
Simple Stepper Code