|
Forum Index : Microcontroller and PC projects : VL53L0X time-of-fligt distance sensor code
| Author | Message | ||||
| ville56 Senior Member Joined: 08/06/2022 Location: AustriaPosts: 262 |
For whom it may be of interest .... I've ported the VL53L0X code from C++ to MMbasic (to my best knowledge, of course). The code is able to handle multiple sensors and is also able to be loaded as library into a PicoMite under MMbasic. The code is tested on a RP2350A and doing fine so far. In the zip-file there is a file for - the library code (can also be included 1:1 in the main code if needed) - a main program to test it (uses a LCD display) - a .txt file with some documentation Comments are welcome, there is certainly much room for improvement and I apologise for my programming style already upfront. It' not very elegant, but it seems to work.VL53L0X.zip maybe someone can use it ... Regards, Gerald 73 de OE1HGA, Gerald |
||||
| stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2667 |
Here's version for ssd1306 oled display. OPTION EXPLICIT OPTION DEFAULT NONE Dim d$ Const i2caddr=&H29 I2C write i2caddr,0,2,&H89,&H1 Font 2 Pause 200 CLS Do getdistance Pause 100 Loop ' Sub getdistance I2C write i2caddr,0,2,0,1 I2C write i2caddr,1,1,&H1E I2C read i2caddr,0,2,d$ text 0,0,(Str$(Str2bin(uint16,d$,BIG),3,0))+" mm " End Sub Edited 2025-09-28 03:31 by stanleyella |
||||
| ville56 Senior Member Joined: 08/06/2022 Location: AustriaPosts: 262 |
Sure, if you do not want control over the sensor you can use the default settings and get away with this very simple code. This is one of the charming features of the VL53LX0. I'd liked to do some experiments to see what one can do with the little beast ... ![]() 73 de OE1HGA, Gerald |
||||
| stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2667 |
Matherp wrote it converted from GBasic. The VL53LX0 is accurate to 10 mm up to 1 M, it's more for gesture control but good for object avoiding robots. https://www.youtube.com/watch?v=s5-5DNa36jk&t=16s |
||||
| ville56 Senior Member Joined: 08/06/2022 Location: AustriaPosts: 262 |
impressive !!! 73 de OE1HGA, Gerald |
||||
TassyJim![]() Guru Joined: 07/08/2011 Location: AustraliaPosts: 6338 |
I played with a pair of modules. https://www.thebackshed.com/forum/ViewTopic.php?TID=16690&PID=217225#217225#217225 The video is no longer available. Jim VK7JH MMedit |
||||
| stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2667 |
it's a small pcb that could be hidden in a walking stick... ultrasonic is okish, use one port on/off quick and it resonates 40khz then make port input and it gets echo back. used to use it for object avoid robots, preferred VL53LX0 for particular application. blind walking stick but surely someone's done that .. commercially? glad more VL53LX0 code posted |
||||
| stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2667 |
mmb i2c is underrated.. imho you can do loads like port expander (for 2 stepper motors), ssd oled and VL53LX0 same time easy. thanks |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |