DIY an Laser Rangefinder,using Arduino&LVGL

by Lan_Makerfabs in Circuits > Arduino

15 Views, 0 Favorites, 0 Comments

DIY an Laser Rangefinder,using Arduino&LVGL

微信图片_20240704103855.jpg

If you're looking to learn Arduino&LVGL, you'll find a whole new world of possibilities for creating innovative projects. In this article, we'll explore the exciting realm of laser rangefinder using Arduino&LVGL. By following these steps, you'll not only gain a better understanding of Arduino&LVGL but also have a functional laser rangefinder of your own.

Supplies

2.png
微信图片_20240704104712.jpg

Single-point TOF Laser Ranging Sensor*1

Matouch -1.9’ display*1

Breadboard*1

Jumper Wires *1

Suitable size carton*1

Decorative Stickers

Paper cutter*1

Hardware

1.png

1: Connecting Matouch -1.9’ display to the breadboard;

2:Connect the Laser Ranging Sensor and the Matouch 1.9" display in the breadboard with jumper cables;

Please note:

Red wire:Power,connect to Matouch-1.9’display 5V

Green wire:RX to Matouch-1.9’display IO3

White wire:TX to Matouch-1.9’display IO1

Black wire:GND to Matouch-1.9’display GND

Create a New Project on LVGL

软件1.png

Add Buttons and Label on Screen

软件2.png

Add Button Event

软件3.png
软件4.png

Change the Color to Your Liking

软件5.png

According to Your Preferences in the "ADD FILE ASSETS" to Add Your Favorite Pictures, Set Your Screen Background

软件6.png

Set the Location of the Export Code and Export UI Files and Create Template Project

软件8.png
软件9.png
软件7.png

After Exporting, Copy LVGL_conf.h to the Src Folder in the LVGL Folder

软件10.png
软件11.png

Open Ui_event.c in the LaserRanging\libraries\ui\src File of the Exported Project Document, Add the Key Event Code and Save

extern int work_flag;

void open_func(lv_event_t *e)

{

// Your code here

lv_obj_add_state(ui_Button1, LV_STATE_DISABLED);

lv_obj_clear_state(ui_Button3, LV_STATE_DISABLED);

work_flag = 1;

}

 

void close_func(lv_event_t *e)

{

// Your code here

lv_obj_add_state(ui_Button3, LV_STATE_DISABLED);

lv_obj_clear_state(ui_Button1, LV_STATE_DISABLED);

work_flag = 0;

}

Copy the Four Files to the Arduino Libraries, Usually in the Form of (C)/Users/Document/arduino/libraries

软件12.png

Open Ui.ino Through the Arduino IDE to Add Your Code

软件13.png

The code of leaser range can be refer to our github page

Note: the Arduino esp32 board should be 2.0.17 and its previous version, we used 2.0.11 version

Modify Your Code

软件15.png
软件14.png

Use the Type-C USB cable to connect the board to the PC, select the development board "ESP32S3 Dev Module" and its port.

Click Upload Code

软件16.png

Make an Enclosure to Put the Hardware Into

微信图片_20240704110455.jpg

Cut the box to size. Secure the assembled hardware inside the box.

Result

微信图片_20240704103855.jpg
微信图片_20240704114237.jpg

As you can see in the picture above, this device works great.This handy little device can test the distance up to 20m and has an accuracy of 3cm. If you're interested, we've got a great tutorial that'll show you how to make your own laser rangefinder.

Detailed Operation Video

How to DIY an laser rangefinder,using basic coding and Modules

To gain a more comprehensive understanding of the assembly testing process, we invite you to view the accompanying video. We look forward to sharing further DIY projects with you in due course.