How to Control Your Linear Actuator Using Light Sensor

by RonFrtek in Circuits > Arduino

108 Views, 1 Favorites, 0 Comments

How to Control Your Linear Actuator Using Light Sensor

How to Control Your Linear Actuator Using Light Sensor

In this Simple tutorial, you will learn how to control the linear actuator using the Light sensor module, Arduino and L298N DC motor driver.

Watch the video!

What You Will Need

2024-10-24_12-11-49.jpg
linear-actuator.jpg
F5OFEUQJJ4ZYFKY.LARGE.jpg
LN298N.jpg
VisuinoAdvrtisemenPortentaC33.png
power-supply1.png
FZEK4WBK3XGYAP0.LARGE.jpg
  1. Arduino UNO (Or any other Arduino)
  2. Linear Actuator
  3. LN298N DC Motor Driver
  4. Light sensor module
  5. Jumper wires
  6. Power Supply
  7. Visuino program: Download Visuino


The Circuit

2024-10-24_12-20-28.jpg
  1. Connect Power supply (batteries) pin (gnd) to motor driver controler pin (gnd)
  2. Connect Power supply (batteries) pin (+) to motor driver controler pin (+)
  3. Connect Power supply (batteries) pin (+) to Arduino pin (VIN)
  4. Connect GND from Arduino to motor driver controler pin (gnd)
  5. Connect digital pin(6) from Arduino to motor driver pin (IN1)
  6. Connect digital pin(8) from Arduino to motor driver pin (IN2)
  7. Connect Linear Actuator to the motor driver as you can see on the schematic
  8. Connect Light Sensor module pin [DO] to arduino digital pin [3]
  9. Connect Light Sensor module pin [VCC] to the Arduino pin [5V]
  10. Connect Light Sensor module pin [GND] to the Arduino pin [GND]


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 & Connect Components

2024-10-24_14-54-53.jpg
2024-10-24_14-55-36.jpg
2024-10-24_14-57-18.jpg
2024-10-24_15-00-47.jpg
actuator-light sensor.png
  1. Add "Speed and Direction To Speed" component
  2. Add "Dual DC Motor Driver Digital and PWM Pins Bridge (L9110S, L298N)" component
  3. Select "SpeedAndDirectionToSpeed1" and in the properties window set "Initial Speed" to 1 or any other speed value that you like


  1. Connect Arduino digital pin [3] to "SpeedAndDirectionToSpeed1" pin [Reverse]
  2. Connect "SpeedAndDirectionToSpeed1" pin [Out] to "DualMotorDriver1" > "Motors [0]" > pin [In]
  3. Connect "DualMotorDriver1" > Motors [0] Pin [Direction]" to Arduino digital pin[8]
  4. Connect "DualMotorDriver1" > Motors [0] Pin [Speed]" to Arduino digital pin Analog PWM[6]


Generate, Compile, and Upload the Arduino Code

Visuino-Compile-UNO.jpg

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 the Linear Actuator will start to move in one direction and if you cover the light sensor module it 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