Control Linear Actuator Using a NEXTION Display and Arduino

by RonFrtek in Circuits > Arduino

643 Views, 2 Favorites, 0 Comments

Control Linear Actuator Using a NEXTION Display and Arduino

Control Linear Actuator Using a NEXTION Display and Arduino

In this Project we will learn how to control a Linear Actuator with Nextion Display and Arduino.

Watch the Video!

What You Will Need

linear-actuator.jpg
51s5Rd4npPL._AC_SY450_.jpg
s-l640.jpg
VisuinoAdvrtisemenESPNowESP32C3-1.jpg
power-supply.png
F5OFEUQJJ4ZYFKY.LARGE.jpg

The Circuit

2023-01-27_11-09-26.jpg
  • Connect Power supply (batteries) pin (gnd) to motor driver controler pin (gnd)
  • Connect Power supply (batteries) pin (+) to motor driver controler pin (+)
  • Connect Power supply (batteries) pin (+) to Arduino pin (VIN)
  • Connect GND from Arduino to motor driver controler pin (gnd)
  • Connect digital pin(6) from Arduino to motor driver pin (IN1)
  • Connect digital pin(8) from Arduino to motor driver pin (IN2)
  • Connect Linear Actuator to the motor driver as you can see on the schematic
  • Connect Nextion Display VCC red wire to Arduino 5V pin
  • Connect Nextion Display GND black wire to Arduino GND pin
  • Connect Nextion Display Yellow wire (RX) wire to Arduino TX pin
  • Connect Nextion Display Blue wire (TX) wire to Arduino RX pin


Nextion Editor

FSLO9CPL01BWKLL.jpg
FBINTKBL01BWKLK.jpg
FDSL8HTL01BWKLI.jpg
2023-01-26_20-07-05.jpg
2023-01-26_20-08-32.jpg
2023-01-26_20-44-38.jpg
2023-01-26_20-45-27.jpg
2023-01-26_20-45-49.jpg
  • Download Nextion Editor and Install it
  • Start Nextion Editor
  • In the Nextion Editor click on the "New" button
  • In the Window set the name for the Project like "ACTUATOR"
  • In the "Setting" window select the Model of your Nextion Display & click "Ok"
  • Select Display Direction 90 & click "Ok"
  • In the Menu select "Tools">"Font Generator"
  • In the Font creator window set the name for your font and click "Generate Font", Save the Font, you will be asked "Add the generated font?" Click Yes
  • In the Editor on the left in the "Toolbox" find "Button" & drag 2 Buttons it to the right
  • For the first button Select it and in the "Attribute" window set "txt" to OPEN and "bco" to Green color
  • For the second button Select it and in the "Attribute" window set "txt" to CLOSE and "bco" to Blue color
  • For both buttons:
  • In the "Event" window > Touch Press Event" Check the "Send component ID"
  • In the "Event" window > Touch Release Event" Check the "Send component ID"
  • In the Toolbar click on the "Compile" button
  • In the Menu Select "File" > "TFT File Output"
  • Set the Output folder & click on the "Output" button
  • Save the File to the SD card
  • Insert the SD card to your Nextion Display
  • Power the Arduino and you will notice that the Nextion Display will start to Update it self
  • On the Finish disconnect the power and remove the SD card from the Nextion display

Start Visuino, and Select the Arduino UNO Board Type

select-board-uno.jpg
Visuino-Select-Board-UNO.jpg

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add, Set & Connect Components

FFHJSRCL0FAE6MB.jpg
2023-01-26_20-49-29.jpg
2023-01-26_20-49-59.jpg
2023-01-26_20-52-11.jpg
2023-01-26_20-52-59.jpg
2023-01-26_20-57-22.jpg
2023-01-25_1-02-26.jpg
2023-01-27_11-31-36.jpg
act-nextion.png
  • Add "Nextion Display" component
  • Double click on the "DisplayNextion1" And in the Elements window drag "Button" to the left side.
  • Drag another "Button" to the Left side and in the properties window set "Element Name" to b1
  • Close the Elements window
  • Add "Analog Value" component
  • Double click on the "AnalogValue1" and in the Elements window drag "Set Value" to the left side and in the properties window set "Value" to 1
  • Drag another "Set Value" to the left side
  • Add "Dual DC Motor Driver Digital and PWM Pins Bridge (L9110S, L298N)" component


  • Connect "DisplayNextion1" > "Button1" Pin[Out] to "AnalogValue1" > "Set Value1" pin [In]
  • Connect "DisplayNextion1" > "Button1" Pin[Out] to "AnalogValue1" > "Set Value2" pin [In]
  • Connect "DisplayNextion1" Pin[Out] to "Arduino" > "Serial [0]" pin [In]
  • Connect AnalogValue1" pin[Out] to "DualMotorDriver1" > "Motors 0" > Pin [In]
  • Connect "DualMotorDriver1" > "Motors 0" Pin [Direction] to Arduino digital pin [8]
  • Connect "DualMotorDriver1" > "Motors 0" Pin [Speed] to Arduino digital pin > Analog PWM [6]

Generate, Compile, and Upload the Arduino Code

2023-01-27_11-23-26.jpg
Visuino-Compile-UNO.jpg

Before Uploading Disconnect RX pin on Arduino and connect it back after the Upload.

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play

If you power the Arduino module and press the on the button "OPEN" on the Nextion Display the Linear Actuator will start to move in one direction and if you press the button "CLOSE" on the Nextion Display the Linear Actuator will reverse.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu