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](/proxy/?url=https://content.instructables.com/FEA/QAVM/LY5UNI8K/FEAQAVMLY5UNI8K.jpg&filename=微信图片_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](/proxy/?url=https://content.instructables.com/F2P/8YSB/LY4F6Z8E/F2P8YSBLY4F6Z8E.png&filename=2.png)
![微信图片_20240704104712.jpg](/proxy/?url=https://content.instructables.com/FSO/07OH/LY5UNIAT/FSO07OHLY5UNIAT.jpg&filename=微信图片_20240704104712.jpg)
Single-point TOF Laser Ranging Sensor*1
Breadboard*1
Jumper Wires *1
Suitable size carton*1
Decorative Stickers
Paper cutter*1
Hardware
![1.png](/proxy/?url=https://content.instructables.com/FC8/EW8G/LY5UNIGU/FC8EW8GLY5UNIGU.png&filename=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](/proxy/?url=https://content.instructables.com/F8L/RLA1/LY4F6Z8X/F8LRLA1LY4F6Z8X.png&filename=软件1.png)
Add Buttons and Label on Screen
![软件2.png](/proxy/?url=https://content.instructables.com/FW3/09U9/LY4F6Z95/FW309U9LY4F6Z95.png&filename=软件2.png)
Add Button Event
![软件3.png](/proxy/?url=https://content.instructables.com/F7M/WBHM/LY4F6Z9E/F7MWBHMLY4F6Z9E.png&filename=软件3.png)
![软件4.png](/proxy/?url=https://content.instructables.com/F8T/9K1J/LY4F6Z9O/F8T9K1JLY4F6Z9O.png&filename=软件4.png)
Change the Color to Your Liking
![软件5.png](/proxy/?url=https://content.instructables.com/FOO/1QSO/LY4F6Z9Z/FOO1QSOLY4F6Z9Z.png&filename=软件5.png)
According to Your Preferences in the "ADD FILE ASSETS" to Add Your Favorite Pictures, Set Your Screen Background
![软件6.png](/proxy/?url=https://content.instructables.com/FJN/UEBA/LY4F6ZAB/FJNUEBALY4F6ZAB.png&filename=软件6.png)
Set the Location of the Export Code and Export UI Files and Create Template Project
![软件8.png](/proxy/?url=https://content.instructables.com/FET/PUW7/LY4F6ZB2/FETPUW7LY4F6ZB2.png&filename=软件8.png)
![软件9.png](/proxy/?url=https://content.instructables.com/F34/V7V0/LY4F6ZBF/F34V7V0LY4F6ZBF.png&filename=软件9.png)
![软件7.png](/proxy/?url=https://content.instructables.com/FG0/U1U4/LY4F6ZAM/FG0U1U4LY4F6ZAM.png&filename=软件7.png)
After Exporting, Copy LVGL_conf.h to the Src Folder in the LVGL Folder
![软件10.png](/proxy/?url=https://content.instructables.com/FX4/W4TY/LY4F6ZBV/FX4W4TYLY4F6ZBV.png&filename=软件10.png)
![软件11.png](/proxy/?url=https://content.instructables.com/FXH/4AGD/LY4F6ZCE/FXH4AGDLY4F6ZCE.png&filename=软件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](/proxy/?url=https://content.instructables.com/FT3/U600/LY4F6ZCW/FT3U600LY4F6ZCW.png&filename=软件12.png)
Open Ui.ino Through the Arduino IDE to Add Your Code
![软件13.png](/proxy/?url=https://content.instructables.com/FUA/IHUZ/LY4F6ZDF/FUAIHUZLY4F6ZDF.png&filename=软件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](/proxy/?url=https://content.instructables.com/FZD/KWD3/LY4F6ZEM/FZDKWD3LY4F6ZEM.png&filename=软件15.png)
![软件14.png](/proxy/?url=https://content.instructables.com/FVO/9XPB/LY4F6ZE1/FVO9XPBLY4F6ZE1.png&filename=软件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](/proxy/?url=https://content.instructables.com/FR0/ADXH/LY4F6ZEN/FR0ADXHLY4F6ZEN.png&filename=软件16.png)
Make an Enclosure to Put the Hardware Into
![微信图片_20240704110455.jpg](/proxy/?url=https://content.instructables.com/FAE/ZZL5/LY5UNJHC/FAEZZL5LY5UNJHC.jpg&filename=微信图片_20240704110455.jpg)
Cut the box to size. Secure the assembled hardware inside the box.
Result
![微信图片_20240704103855.jpg](/proxy/?url=https://content.instructables.com/FWP/3WJ3/LY5UNJLO/FWP3WJ3LY5UNJLO.jpg&filename=微信图片_20240704103855.jpg)
![微信图片_20240704114237.jpg](/proxy/?url=https://content.instructables.com/FEY/02SB/LY5UNK6U/FEY02SBLY5UNK6U.jpg&filename=微信图片_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](/proxy/?url=https://content.instructables.com/FX7/FZH1/LY5UNJTG/FX7FZH1LY5UNJTG.jpg&filename=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.