Figure 1
#Project Origin#
This article is from: Wangzai Dad Creation Society
Author: Wangzai Dad
Spring Festival is the most traditional and grand festival in China. The customs of the Spring Festival include posting couplets, setting off firecrackers, and visiting relatives and friends. Of course, the warmest moment is when the family gathers on New Year’s Eve to have a reunion dinner and watch the Spring Festival Gala. To celebrate the upcoming Year of the Tiger Spring Festival, Wangzai Dad created a unique page-turning display, which I named Page-turning display.
Figure 2 Page-Turning Display
Since it is a display, it must have a screen. However, this screen is not electronic but rather an older page-turning style, similar to the effect of quickly flipping through a book. In fact, the videos played on screens in our daily lives also switch frames rapidly, so quickly that the human eye cannot perceive it. Our page-turning display aims to recreate this display principle.
Let’s first watch a video to see how the page-turning display works.
#Video Display#
#Design and Production#
We designed the page-turning display to resemble a retro television, using laser cutting technology to process the linden wood and acrylic boards to create the appearance structure of the page-turning display. Figure 3 shows the effect diagram.
Figure 3 Simulation of the Page-Turning Display Effect
#Plan Introduction#
From the preliminary observation of the simulation diagram above, we can see that the page-turning display consists of three parts: the rotating display part, the outer frame part, and the electronic control part.
For the driving motor of the rotating display part, there are many options available, such as stepper motors, DC geared motors, and servos. Since the load of this rotating part is not very large and the speed requirement is not high, while also needing to precisely control the rotation angle, we chose the cost-effective 28BYJ-48 micro stepper motor, which can work with the ULN2003 driver, greatly reducing the difficulty of use and minimizing the space volume. The stepper motor is shown in Figure 4.
Figure 4 28BYJ-48 Micro Stepper Motor
After solving the key driving part, we chose Arduino Nano as the main control board, adding a Hall sensor combined with a magnet to achieve the function of recording the number of rotations. The specific details are shown in Figure 5.
Figure 5 Internal View of the Page-Turning Display
Once the plan is determined, we can start designing the appearance structure of the page-turning display.
#Drawing Design#
We used the LaserMaker laser modeling software to design the drawings.
You can download the modeling software from the official website: https://www.lasermaker.com.cn/
Figure 6 LaserMaker Software Download
After the installation is complete, open the software, and the interface is shown in Figure 7.
Figure 7 LaserMaker Software Running Interface
In the LaserMaker software, we designed the retro television shape as shown in Figure 8. For the page-turning part used to display images, we used 1mm thick transparent acrylic board, while for other structural parts, we chose 3mm thick linden wood. To increase the interactivity of the work, we designed a magic wand as the start-stop switch for the page-turning display.
Figure 8 Page-Turning Display Design Diagram
As for the animation stickers for the page-turning display, they need to be searched online for New Year animation materials (or favorite anime materials), modified to the same size as the parts, printed out, and pasted on the acrylic board.
Figure 9 Stickers and Acrylic Board
Figure 10 Stickers Pasted on the Acrylic Board
#Processing Parts#
After the drawing design is completed, we used a laser cutting machine to process it, and the parts after cutting are shown in Figure 11.
Figure 11 Physical Diagram of Parts After Laser Cutting Processing
#Equipment List#
In addition to the appearance structure, this page-turning display also requires the following parts:
-
Arduino Nano controller and expansion board *1
-
Hall sensor *2
-
28BYJ-48 stepper motor *1
-
ULN2003 stepper motor driver *1
-
Switch *1
-
DC power interface *1
-
3mm linden wood *1 (40cm*60cm)
-
1mm transparent acrylic board *2 (40cm*60cm)
-
Dupont wires several
-
3mm to 5mm coupling *1
-
20cm D-shaft *1
-
Various hardware parts
Figure 12 Equipment List for Page-Turning Display
Once the equipment is ready, let’s take a look at how the electronic control part is connected.
#Circuit Wiring#
The circuit wiring of the page-turning display is shown in Figure 13.
The stepper motor connects to the controller’s digital pins 4-7, and the two Hall sensors connect to digital pins 2 and 3, respectively. One Hall sensor serves as the start-stop switch, while the other Hall sensor is used to detect how many turns the magnet on the disc has made.
Figure 13 Schematic Diagram of the Page-Turning Display Circuit Wiring
With everything ready, we can start assembling the project.
#Assembly#
The assembly of the page-turning display is not very complicated, but it still requires careful installation step by step.
Step 1: Install Electronic Components
First, we install the switch for the page-turning display. For this project, we chose a retro-style push button switch and installed it on the front wooden board, as shown in Figures 14 and 15.
Figure 14 Installing the Push Button Switch
Figure 15 Push Button Switch Installed
Next, install the controller, stepper motor, driver, and power interface. Figure 16 shows the required parts.
Figure 16 Electronic Components
The installation of the main control and stepper motor components is shown in Figure 17.
Figure 17 Main Control and Stepper Motor Installation Completed
Next, install the Hall sensors that record the number of rotations, as shown in Figure 18 after installation.
Figure 18 Hall Sensors Installed
Step 2: Assemble the Frame Structure
Once the electronic components are installed, the next step is to assemble the frame. The frame consists of 5 parts and can be assembled according to the slots.
Figure 19 Parts Needed for Frame Assembly
The completed frame assembly is shown in Figure 20.
Figure 20 Frame Assembly Completed
After completing the frame, we need to install the rotating skeleton for the page-turning display, and the required parts are shown in Figure 21.
Figure 21 Parts Needed for Rotating Skeleton Installation
During assembly, the D-shaft needs to be installed in the rectangular box, and discs need to be installed on both sides of the box. The installation is shown in Figure 22.
Figure 22 Rotating Skeleton Installed
Once the rotating skeleton assembly is completed, it needs to be combined with the frame, as shown in Figure 23.
Figure 23 Rotating Skeleton Combined with the Frame
Using a 5mm to 3mm coupling, connect the stepper motor with the D-shaft. On the other side, to ensure the flexibility of the shaft during rotation, a bearing can be installed in the hole, as shown in Figure 24 after installation.
Figure 24 Rotating Skeleton and Frame Combined Completed
The next step is to install the front wooden board on the frame.
Figure 25 Front Wooden Board Combined with the Frame
Figure 26 Front Wooden Board Combined Completed
Step 3: Install the Display Part and Others
Now, the overall effect of the “television” is taking shape. If we can add an antenna, it will be even more “soulful”. Let’s install the antenna and the magic wand used for start-stop on the “television”.
Figure 27 Parts Needed for Installing Antenna and Magic Wand
Don’t forget to put a magnet in the middle of the magic wand. The installation is shown in Figure 28.
Figure 28 Antenna and Magic Wand Installed
Finally, we install the most important display image in the skeleton of the display. The assembly of the page-turning display is complete.
Figure 29 Display Image Installed
When installing the acrylic image, align it with the holes on both sides of the discs. The completed effect of the page-turning display is shown below.
Figure 30 Display Image Installation Completed
Figure 31
The project assembly is complete. Next, we will write the program to give the project its soul.
#Program Design#
This project uses the Arduino IDE as the programming environment. You can download the programming environment from the official website arduino.cc.
Figure 32
Of course, you can also download the latest Mixly graphical programming software from mixly.org, which integrates the Arduino IDE programming environment, saving a lot of configuration trouble.
#Programming Ideas#
The page-turning display we created uses a stepper motor to make the page-turning animation display work, using two Hall sensors to control the animation playback and record the number of rotations. Therefore, the use of the stepper motor and Hall sensors is the key to the programming design of this project. We will gradually complete it based on the programming ideas.
Figure 33 Program Design Mind Map
#Using Hall Sensors#
Background Knowledge
The Hall sensor is based on the Hall effect and can be used to detect magnetic materials (magnets).
What is the Hall effect? The Hall effect was discovered by physicist Hall in 1879. When a magnetic field approaches a conductor with current flowing through it, the electrons in the conductor will be deflected to one side due to the influence of the magnetic field, forming a potential difference in the conductor. This is the Hall effect, and this phenomenon can be used to detect magnetic materials. Common Hall sensors include switch-type Hall sensors and linear Hall sensors. Linear Hall sensors output analog signals, while switch-type Hall sensors output digital signals.
In this project, we only need to use Hall sensors to control the start and stop of the page-turning display, so we only need switch-type Hall sensors.
The programming method for Hall sensors is very simple; it can detect whether a magnet is present or not. We input the following program in the programming environment to test the status of the Hall sensor.
#define Hall_START 2 //Hall sensor pinint START;//Start state storage variablevoid setup(){ pinMode(Hall_START, INPUT);//START Serial.begin(9600); }void loop(){ START = digitalRead(Hall_START);//Store the state of the Hall sensor Serial.println(START); delay(1000);}
The program running results are shown in Figure 34.
When the magnet is close, the signal is 0; when the magnet is far away, the signal is 1.
Figure 34 Hall Sensor Test
Similarly, the second Hall sensor can be tested using the same method.
We will continue to modify the program based on the existing setup.
#define Hall_START 2 //Hall sensor pin#define Hall_END 3 //Hall sensor pinint START;//Start state storage variableint END;//End state storage variablevoid setup(){ pinMode(Hall_START, INPUT);//START pinMode(Hall_END, INPUT);//END Serial.begin(9600);}void loop(){ START = digitalRead(Hall_START);//Store the state of Hall sensor 1 END = digitalRead(Hall_END);//Store the state of Hall sensor 2 Serial.print(F("Hall Sensor 1 Status:")); Serial.println(START); delay(1000); Serial.print(F("Hall Sensor 2 Status:")); Serial.println(END); delay(1000);}
The effect after running the program is shown in Figure 35.
Figure 35 Testing Two Hall Sensors Simultaneously
Thus, both Hall sensors can be controlled.
Next, we will enrich the program and set it to start working when the magnet is near the Hall sensor for more than 0.5 seconds. The program is as follows.
#define Hall_START 2 //Hall sensor pin#define Hall_END 3 //Hall sensor pin#define OVER 1 //Determine if it has entered the final stageint START;//Start state storage variableint END;//End state storage variablebool is_working = false;//Workingbool is_free = true;//Idleint count=0;//Counterint SPEED=0;//speedchar MODEL; //Modevoid setup(){ pinMode(Hall_START, INPUT);//START pinMode(Hall_END, INPUT);//END Serial.begin(9600);}void loop(){if(START == 1 && digitalRead(Hall_START) == 0)//Two detections of button state { delay(500);if ( digitalRead(Hall_START) == 0 && is_free == true) //If the device is in idle state, enter working mode { is_free = false; is_working = true; } } START = digitalRead(Hall_START);//Store the state of Hall sensor 1 END = digitalRead(Hall_END);//Store the state of Hall sensor 2//Start workingif(is_free == false && is_working == true ) { Serial.println(F("Working")); //Counter counts, ignoring the first detection state count++; Serial.println(count); if(count >500) { MODEL = OVER; } }//End workingif (MODEL == OVER && END == 0) { Serial.println(F("End Working")); count = 0;//Reset counter is_working = false;//Reset working indicator variable is_free = true;//Reset idle indicator variable MODEL = 0;//Reset state }}
In the program, we set the variables “START” and “END” to store the values of the two Hall sensors, use the variables “is_free” and “is_working” to mark the working state, and use the variable “MODEL” to store the working state. When the magnet approaches Hall sensor 1 and remains for more than 0.5 seconds, it can start to enter the working state, while the variable “count” begins to count. When the variable “count” reaches 500, it ends working and resets all variable states.
The running result after downloading the program is shown in Figure 36. When the magnet approaches the Hall sensor for more than 0.5 seconds, counting starts, and when the counter value exceeds 500, it stops working.
Figure 36 Hall Sensor Start-Stop Test
Thus, we have achieved the function of using a magnet to control start and stop. Next, we only need to add the program for the stepper motor rotation to achieve the actual page-turning action.
#Stepper Motor Knowledge#
Background Knowledge
The stepper motor we chose this time is the 28BYJ-48 stepper motor, which is fully named the permanent magnet unipolar four-phase stepper motor. Such a complicated name can be a bit daunting.
Let’s first look at the origin of the name 28BYJ-48 stepper motor.
-
28: The effective maximum outer diameter of the stepper motor is 28 millimeters.
-
B: Indicates it is a stepper motor.
-
Y: Indicates it is permanent magnet type.
-
J: Indicates it is a geared type (gear ratio 1:64).
-
48: Indicates four-phase eight-step.
In other words, the meaning of 28BYJ-48 is a 28mm outer diameter four-phase eight-step permanent magnet geared stepper motor. Isn’t that a bit confusing? Don’t worry, we will look at it step by step.
Usually, motors are divided into stators and rotors. Each tooth of the rotor has a permanent magnet, which is the concept of permanent magnet type.
The stator is on the outer ring, with 8 teeth, each wound with coils, two by two to be turned on or off, thus forming 4 phases. This is the concept of four phases. As for eight steps, we will not elaborate on it here; you can simply understand it as the order of powering the 4 groups of coils.
Next, let’s explain the concept of “gearing” in the name. Figure 37 shows the disassembly diagram of the 28BYJ-48 stepper motor.
Figure 37 Internal Diagram of 28BYJ-48 Stepper Motor
From the diagram, we can see that the white small gear in the center is the rotor shaft of the stepper motor. A small gear drives a large gear for one level of gearing. The motor shown in the diagram has a total of 4 levels of gearing. So, what is the total gear ratio? That is, how many turns does the rotor make for the output shaft to make one turn?
Looking back at the gear ratio parameter in the motor parameter table, it is 1:64, which means the rotor turns 64 times for the output shaft to turn once. Regardless of the manufacturer that produces the motor, as long as the model is 28BYJ-48, the rated gear ratio is 1:64.
This concludes the basic control principle.
Figure 38 Diagram Explaining Stepper Motor Gear Ratio
In fact, controlling a stepper motor with just a controller is quite difficult; a driver is needed to drive the stepper motor. The ULN2003 driver is a good companion for the 28BYJ-48 stepper motor, and they usually appear together.
Once you are familiar with the 28BYJ-48 stepper motor, we can write a program to control it. We can choose the built-in【Stepper】 library in Arduino IDE or the third-party library【AccelStepper】.
Since the built-in【Stepper】 library cannot work with other programs when controlling the stepper motor, we need to use the simple, easy-to-use, and powerful【AccelStepper】 third-party library to allow Arduino to control the stepper motor while completing other tasks.
Installing the AccelStepper Library
In the Arduino IDE programming environment, click on the【Library Manager】 option in the tools menu, enter【AccelStepper】 in the input bar, and click install, as shown in Figure 39.
Figure 39 Installing the AccelStepper Library
Once installed, you can use this library to control the stepper motor.
We input the following program in the programming environment.
#include "AccelStepper.h"// Stepper motor stepping method definition#define FULLSTEP 4 //Full step parameter#define HALFSTEP 8 //Half step parameter// Define stepper motor pins#define motor1Pin1 4 // 28BYJ48 connected to ULN2003 driver pin in1#define motor1Pin2 5 // 28BYJ48 connected to ULN2003 driver pin in2#define motor1Pin3 6 // 28BYJ48 connected to ULN2003 driver pin in3#define motor1Pin4 7 // 28BYJ48 connected to ULN2003 driver pin in4// Define stepper motor object// Define the order of ULN2003 driver pins as in1-in3-in2-in4// The motor is set to run in full step modeAccelStepper stepper(FULLSTEP, motor1Pin1, motor1Pin3, motor1Pin2, motor1Pin4);void setup(){ stepper.setMaxSpeed(500.0); // Maximum speed of the motor stepper.setAcceleration(50.0); // Motor acceleration Serial.begin(9600); }void loop(){if ( stepper.currentPosition() == 0 ) {// Motor rotates one round stepper.moveTo(2048); } else if ( stepper.currentPosition() == 2048 ) {// Motor rotates one round stepper.moveTo(0); } stepper.run(); // Motor runs}
In the program, we set the maximum running speed of the stepper motor using【setMaxSpeed】, set the acceleration of the stepper motor using【setAcceleration】, use【currentPosition】 to get the current position of the stepper motor, and the【moveTo】 command can set the absolute target position of the stepper motor, which means to rotate to a specified angle. Here, the position of the stepper motor when powered on is 0.
After running the program, we will see that the stepper motor will rotate one full turn and then stop. Why is stepper.moveTo(2048) one full turn? What does 2048 refer to?
The step angle of the four-phase eight-step stepper motor is 11.25°, and the rotor needs to take 32 steps to make one full turn (360/11.25=32). With a gear ratio of 1:64, the output shaft needs 32*64=2048 steps to make one full turn. Therefore, stepper.moveTo(2048) actually refers to the number of steps the output shaft takes to make one full turn, of course, this is under the full step parameter “#define FULLSTEP 4”. If it is half step “#define HALFSTEP 8”, the stepper will need 4096 steps to complete one full turn.
In addition, the【AccelStepper】 library also provides some other commonly used functions, as follows:
Common Functions and Operations
-
setCurrentPosition – Reset the initial position of the stepper motor
Using the setCurrentPosition function can modify the value of the current position. For example, if the current position of the stepper motor is 0, inputting stepper.setCurrentPosition(512) will change the original position of 0 to 512.
Figure 40 Diagram Explaining setCurrentPosition Function
-
move – Set the relative target position for the stepper motor
stepper.move(1024); // Using move function can make the stepper motor run the corresponding number of steps.
For example, if the current position of the stepper motor is 0, move(512) will make the stepper motor point to position 512. Another move(512) command will make the stepper motor point to position 1024.
Figure 41 Diagram Explaining move Function
-
moveTo – Set the absolute target position for the stepper motor
Using the moveTo command can make the stepper motor rotate to a specified angle. For example, moveTo(1024) will make the stepper motor point to position 1024. If you input the moveTo(1024) command again, the stepper motor will not move since it is already at position 1024.
Figure 42 Diagram Explaining moveTo Function
-
runToNewPosition – Let the motor run to the user-specified position value, where the target position is absolute.
stepper.runToNewPosition(2048); // Using runToNewPosition function lets the motor run to the user-specified position value.
The runToNewPosition command is similar to the previous moveTo command, but the difference is that the runToNewPosition command will not continue executing subsequent program content until the stepper motor reaches the target position.
Figure 43 Diagram Explaining runToNewPosition Function
-
setSpeed – Set the running speed of the stepper motor
-
run – Stepper motor runs (accelerating and decelerating mode)
-
runSpeed – Stepper motor runs (constant speed mode)
If you want the stepper motor to rotate at a constant speed, you need to use setSpeed to set the running speed of the stepper motor and the runSpeed() function.
For example, inputting the following two lines of code will make the stepper motor run at a constant speed of 300.
stepper.setSpeed(300); // Initialize motor speed to 300stepper.runSpeed();
The above is an introduction to commonly used functions of the AccelStepper library (here we quote the materials provided by the Taiji Maker Team, thanks to Taiji Maker for their contributions to the maker community). There are many functions of the AccelStepper library that are not listed here. We believe that after mastering the above functions, it will be easier to understand and master other functions of the AccelStepper library. If you need more information about using the AccelStepper library, please refer to http://www.airspayce.com/mikem/arduino/AccelStepper/index.html.
In this page-turning display, we only need to make the stepper motor run at a constant speed.
We will combine the previous Hall sensor program with the stepper motor program to complete the program control of the page-turning animation display.
The complete program is as follows.
#include "AccelStepper.h"// Stepper motor stepping method definition#define FULLSTEP 4 //Full step parameter#define HALFSTEP 8 //Half step parameter// Define stepper motor pins#define motor1Pin1 4 // 28BYJ48 connected to ULN2003 driver pin in1#define motor1Pin2 5 // 28BYJ48 connected to ULN2003 driver pin in2#define motor1Pin3 6 // 28BYJ48 connected to ULN2003 driver pin in3#define motor1Pin4 7 // 28BYJ48 connected to ULN2003 driver pin in4#define Hall_START 2 //Hall sensor pin#define Hall_END 3 //Hall sensor pin#define OVER 1 //Determine if it has entered the final stage// Define stepper motor object// Define the order of ULN2003 driver pins as in1-in3-in2-in4// The motor is set to run in full step modeAccelStepper stepper(FULLSTEP, motor1Pin1, motor1Pin3, motor1Pin2, motor1Pin4);int START;//Start state storage variableint END;//End state storage variablebool is_working = false;//Workingbool is_free = true;//Idleint count=0;//Counterint SPEED=0;//speedchar MODEL; //Modevoid setup(){ pinMode(Hall_START, INPUT);//START pinMode(Hall_END, INPUT);//END stepper.setMaxSpeed(500.0); // Maximum speed of the motor stepper.setSpeed(0); // Initialize motor speed to 0 Serial.begin(9600);//Reset to initial positionwhile(digitalRead(Hall_END) == 1) { stepper.setSpeed(100); stepper.runSpeed(); } stepper.setSpeed(0); stepper.runSpeed(); }void loop(){if(START == 1 && digitalRead(Hall_START) == 0)//Two detections of button state { delay(500);if ( digitalRead(Hall_START) == 0 && is_free == true) //If the device is in idle state, enter working mode { is_free = false; is_working = true; } } START = digitalRead(Hall_START);//Store the state of Hall sensor 1 END = digitalRead(Hall_END);//Store the state of Hall sensor 2//Start workingif(is_free == false && is_working == true ) { SPEED = 100; //Counter counts, ignoring the first detection stateif(count >500) { MODEL = OVER; } count++; }//End workingif (MODEL == OVER && END == 0) { SPEED = 0;//Speed reset count = 0;//Reset counter is_working = false;//Reset working indicator variable is_free = true;//Reset idle indicator variable MODEL = 0;//Reset state } Serial.println(count); stepper.setSpeed(SPEED); stepper.runSpeed();}
Figure 44
At this point, the page-turning display is fully completed.
#Summary#
In this project, we mastered the working principle of the Hall sensor, learned how to use the 28BYJ-48 stepper motor, and with these skills, more interesting animation content can be easily displayed, such as various anime-themed materials. So what are you waiting for? Go ahead and give it a try!
The Year of the Tiger Spring Festival is coming soon. Finally, I wish everyone a happy and prosperous new year!
This article is from: Wangzai Dad Creation Society
Author: Wangzai Dad


Recommended Reading:
-
Python Programming Advanced Series Course – 10 Park Assistant
-
Python Programming Advanced Series Course – 09 Weather Alarm Clock
-
Python Programming Advanced Series Course – 08 Smart Voice Switch
-
Python Programming Advanced Series Course – 07 Smart Kitchen Security System
-
Python Programming Advanced Series Course – 06 Plant Monitoring Instrument
-
Python Programming Advanced Series Course – 05 Aquarium Automatic Water Level Control
-
Python Programming Advanced Series Course – 04 Wearable Pedometer
-
Python Programming Advanced Series Course – 03 DIY Communication Device (Part 2)
-
Python Programming Advanced Series Course – 03 DIY Communication Device (Part 1)
-
Python Programming Advanced Series Course – 02 Simple Weather Station
-
Python Programming Advanced Series Course – 01 Fun Digital Conductivity Meter
-
Python Programming Advanced Series Course – Tutorial Usage Instructions
Click “Read the Original” to learn more!