Here I did some VL53LOX code adjustments for steady terminal readings without errors.
It works great on my Arduino Nano but should work on a Uno too!
#chipmega328p, 16
#optionExplicit;for terminal distance out
#defineUSART_BAUD_RATE9600
#defineUSART_TX_BLOCKING
#defineUSART_DELAY1ms;set up v53l0x
#defineHI2C_DATAPORTC.5;sda
#defineHI2C_CLOCKPORTC.4;scl
#defineHI2C_BAUD_RATE400HI2CModeMasterdimdistance_lo,distance_hiasbytedimdistanceasWordHI2CStart;software restartHI2CSend(0x52)HI2CSend(0x89)HI2CSend(0x01)HI2CStopwait200msdo;Sys Range StartHI2CStartHI2CSend(0x52)HI2CSend(0x00)HI2CSend(0x01)HI2CStop;read distanceHI2CStartHI2CSend(0x52)HI2CSend(0x1e)HI2CReStartHI2CSend(0x53);set the read flagHI2CReceive(distance_hi, ACK)HI2CReceive(distance_lo, NACK)HI2CStop'Code adjustments for steady readings without errors.distance=distance_hi*256+distance_loSelectCasedistanceCase0'Skip errorsCase20'Skip errorsCase<9hserprint" Distance: "+str(distance)+" mm ";HSerPrintCRLFCase<99hserprint" Distance: "+str(distance)+" mm ";HSerPrintCRLFCase<999hserprint" Distance: "+str(distance)+" mm ";HSerPrintCRLFCase<2000hserprint" Distance: "+str(distance)+" mm ";HSerPrintCRLFCase>2000'Skip maximal errorsEndSelectloop
Last edit: Haroen 2021-01-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
;set up V53L0X
#defineHI2C_DATAPORTC.5;sda portc.4 for nano portc.5 for uno
#defineHI2C_CLOCKPORTC.4;scl portc.5 for nano portc.4 for uno
#defineHI2C_BAUD_RATE400HI2CModeMaster
so I know it works but dunno where my confusion came from.
I had no results from TOF 10120.
tried i2c to terminal and serial to spi display. maybe broke but doubt it.
any info on tof10120?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I been working on it but will try again,
like what is serial? distance and mm as 5 bytes so is that continuous?
set up device as usart and terminal as usart1.. dunno.
I checked it's id with i2c finder . brain ache
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks, also putting
#include <mega2560.h>
helped.Excellent stuff. It is cool to discover the solution!
Here I did some VL53LOX code adjustments for steady terminal readings without errors.
It works great on my Arduino Nano but should work on a Uno too!
Last edit: Haroen 2021-01-17
Nice you got it working.
;set up v53l0x
for some reason I thought these were swapped but it's the lgt328 that has the pins swapped
No,not swapped,your code?
pc.5 is scl
Last edit: stan cartwright 2021-01-17
I copied this from a robot vehicle code
so I know it works but dunno where my confusion came from.
I had no results from TOF 10120.
tried i2c to terminal and serial to spi display. maybe broke but doubt it.
any info on tof10120?
yes, I checked C.5 scl on the Nano leg a5.
I will try the TOF10120 with gcb
I been working on it but will try again,
like what is serial? distance and mm as 5 bytes so is that continuous?
set up device as usart and terminal as usart1.. dunno.
I checked it's id with i2c finder . brain ache
He Stan, for the TOF10120 I will post in your other topic TOF10120 conversion.
ok. I just been looking. at https://sourceforge.net/p/gcbasic/discussion/579126/thread/1fe0a785f5/
the vl0x an tof 10120 seem to have mixed on the thread.