Easy Basics Project 004c 28 BYJ - 48 Stepper Motor with LEDs and LCD1602 I2C

of Acoptex.com in UNO

Basics: Project 004c

Project name: 28 BYJ - 48 Stepper Motor with LEDs and LCD1602 I2C

Attachments: libraries and program

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.BYJ 48 Stepper Motor

3.Arduino IDE ( you can download it from here  )

4.Jumper cables

5.ULN2003 stepper motor driver board

6. LEDs 3 pcs (1 Blue, 1 Green, 1 Red)

7. Resistors 3 pcs (220 Om each)

8. LCD1602 module

9. Breadboard

Understanding the stepper motors

See more details here. We will use unipolar stepper motor 28BYJ-48 for this project.

There are many types of drivers - L293, ULN2003, A3967SLB and more. 

The 28BYJ-48 even comes with breakout using ULN2003 as a motor driver chip.

Understanding LCD 1602 module

 See more details here - check this project

Signals and contacts stepper motor, ULN2003 module, LEDs, LCD 1602 module

Signals and connections of stepper motor, ULN2003 module, LEDs  you can find here.

Signals and connections of LCD1602 module you can find here.


The following table and picture shows the needed connections with the Arduino Uno.

The following table and picture shows the needed connections with the Chinese Uno.

See the video here: https://youtu.be/bNb7FrqBpio

Step by Step instruction

  1. Plug your Adruino Uno board into your PC and select the correct board and com port
  2. Find your I2C address. Each device has an I2C address that it uses to  accept commands or send messages. Load the sketch over at http://arduino.cc/playground/Main/I2cScanner and follow the instructions to use it.  By opening up the Serial monitor window after you upload the sketch, Arduino will scan the address range looking for a reply.  Even though the documentation said it was 0x27, this scanner can detect different (in my case 0x3F)
  3. Modify the sketch in attachments above (you can use the sketch below too): the line LiquidCrystal_I2Clcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) (See part marked bold)
  4. You must take something in consider: 28BYJ-48 has a gear ratio of 64 and stride angle 5.625 so this motor has a 4096 Steps. Number of Steps in one revolution= 360/stride angle=360/5.625=64. Steps =Number of steps in One Revolution * Gear ratio. Steps= (360/5.625)*64 = 64 * 64 =4096 - this value will substitute it in the arduino sketch. 
  5. For Adafruit Stepper Motor the stride angle 7.5 and gear ratio is 16. So number of steps in 1 revolution will be : steps in One Revolution  = 360 / 7.5 = 48. Steps= 48 * 16 = 768. It will be different depending on what motor you are using so check the datasheet for your stepper motor to calibrate these values.
  6. Verify and upload the the sketch to your Adruino Uno.



  • See attachments on the begining of this project description.
  • The Stepper and Wire library included in Adruino IDE program which installed in your PC.
  • I have used the library - NewliquidCrystal_1.3.4.zip which I downloaded, unzipped, changed the name of folder to LiquidCristal and added to libraries in my PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
  • If you have LiquidCristal folder in this location already - delete this folder and copy folder, which was made by you, to this location.


  name: BYJ48 Stepper motor code
  function: This program drives a unipolar or bipolar stepper motor.
  Blue LED blinks 2 times then the motor moves 1000 steps in one direction
  (Green LED is on), then 1000 in the other (Red LED is on). 
  Added LCD1602 module with comments on each step of program.
// include the library code
#include <Stepper.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define motorSteps 64     // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 8
#define motorPin2 10
#define motorPin3 9
#define motorPin4 11
#define ledPin1 6
#define ledPin2 7
#define ledPin3 13
// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1, motorPin2, motorPin3, motorPin4);
// initialise the LCD:
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup() {
  // set the motor speed at 200 RPMS:
  // Initialize the Serial port:
  // set up Green and Red LED pins:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  // set up the Blue LED pin:
  pinMode(ledPin3, OUTPUT);
void loop() {
  //Define the LCD as 16 column by 2 rows
  lcd.begin (16, 2);
  //Switch on the backlight
  //goto first column (column 0) and first line (Line 0)
  lcd.setCursor(0, 0);
  // Start the program:  
  // Print at cursor Location:
  lcd.print("Start program");
  Serial.println("Start program");
  // blink the LED 2 times:
  // Step right 1000 steps:
  lcd.setCursor(0, 0);
  lcd.print("Turn right");
  Serial.println("Turn right");
  digitalWrite(ledPin1, HIGH);
  digitalWrite(ledPin1, LOW);
  // Stop:
  lcd.setCursor(0, 0);
  // Step left 1000 steps:
  lcd.setCursor(0, 0);
  lcd.print("Turn left");
  Serial.println("Turn left");
  digitalWrite(ledPin2, HIGH);
  digitalWrite(ledPin2, LOW);
  // Stop:
  lcd.setCursor(0, 0);
  // Finish program:
  Serial.println("Finish program");
  lcd.setCursor(0, 0);
  lcd.print("Finish program");
// Blink the blue LED:
void blink(int howManyTimes) {
  int i;
  for (i = 0; i < howManyTimes; i++) {
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin3, LOW);

Other projects of Acoptex.com
Easy Merry Xmas to everyone of Acoptex.com, Not selected 24-12-2019

Published at 01-05-2017
Viewed: 1343 times