This project will make BYJ48 Stepper Motor to make clockwise and counter clockwise rotating. Flowing pictures show the stepper motor and connection bridge circuit board:
Step 1 – Connect board, Bridge board and Stepper Motor as per following graph:
Step 2 – Download stepper.ino sketch file and load it into Arduin. The step motor will start to rotate clockwise and counter clockwise.
Project Demo Video:
公式ストアは下記のリンクをクリック
DownLoad Url osoyoo.com
You must be logged in to post a comment.
How do you control the speed of the motor with a potentiometer?
I am using the following code, but it is not working. The motor seems as if it is trying to do something, but I think it is just stepping back and forth.
/*
Stepper Motor Control – speed control
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 – 11 of the Arduino.
A potentiometer is connected to analog input 0.
The motor will rotate in a clockwise direction. The higher the potentiometer value,
the faster the motor speed. Because setSpeed() sets the delay between steps,
you may notice the motor is less responsive to changes in the sensor value at
low speeds.
Created 30 Nov. 2009
Modified 28 Oct 2010
by Tom Igoe
*/
/*
* * LCD Pin Setup:
* LCD -> Ardunio
* GND -> GND
* VCC -> 5V
* SDA -> A4
* SCL -> A5
*/
#include
#include
LiquidCrystal_I2C lcd(0x3f,16,2); // run ic2_scanner sketch and get the IC2 address, which is 0x3f in my case,it could be 0x3f in many cases
const int stepsPerRevolution = 300; // 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);
int stepCount = 0; // number of steps the motor has taken
void setup() {
// nothing to do inside the setup
lcd.init(); // initialize the lcd
}
void loop() {
// read the sensor value:
int sensorReading = analogRead(A0);
// map it to a range from 0 to 100:
int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
// set the motor speed:
if (motorSpeed > 0) {
myStepper.setSpeed(motorSpeed);
// step 1/100 of a revolution:
myStepper.step(stepsPerRevolution / 100);
//Display MotorSpeed
lcd.setCursor(0, 0);
lcd.backlight();
lcd.print(“Motor Speed”);
lcd.setCursor(0, 1);
lcd.print(” “);
lcd.setCursor(0, 1);
lcd.print(motorSpeed);
}
}
Hi,James,
there is sth wrong with your code,try to add
#include
#include
at the head of your sketch