| Posted: 09:54am 21 Feb 2026 |
Copy link to clipboard |
 Print this post |
|
Depending on the application a basic laser distance sensing module may be suitable. The circuit is nothing more than I2C data and clock plus 3.3V and ground. Very cheap on AliExpress.
Example MMBasic code for a VL53L0X on a PicoMite. For other MMBasic platforms the only difference is likely to be the way I2C is setup. The relevant manual will have the details in the I2C Appendix.
'VL53L0X LASER distance using PicoMite System I2C on I2C channel 1 'change all I2C to I2C2 if System I2C is on channel 2
Dim Integer dist Const VLaddr=&H29 'VL53L0X I2C address ' Do VL53L0X Print dist;" mm" Pause 2000 Loop
Sub VL53L0X Local Integer dst(1) I2C write VLaddr,0,2,0,1 'trigger VL53L0X measurement Pause 75 'allow time to perform measurement I2C write VLaddr,1,1,30 'prepare to read I2C read VLaddr,0,2,dst() 'get the data dist = (dst(0)<<8) + dst(1) - 20 'assemble the bytes and subtract the 20mm offset. End Sub Edited 2026-02-21 21:57 by phil99 |