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;forterminaldistanceout#defineUSART_BAUD_RATE9600#defineUSART_TX_BLOCKING#defineUSART_DELAY1ms;setupv53l0x#defineHI2C_DATAPORTC.5;sda#defineHI2C_CLOCKPORTC.4;scl#defineHI2C_BAUD_RATE400HI2CModeMasterdimdistance_lo,distance_hiasbytedimdistanceasWordHI2CStart;softwarerestartHI2CSend(0x52)HI2CSend(0x89)HI2CSend(0x01)HI2CStopwait200msdo;SysRangeStartHI2CStartHI2CSend(0x52)HI2CSend(0x00)HI2CSend(0x01)HI2CStop;readdistanceHI2CStartHI2CSend(0x52)HI2CSend(0x1e)HI2CReStartHI2CSend(0x53);setthereadflagHI2CReceive(distance_hi,ACK)HI2CReceive(distance_lo,NACK)HI2CStop'Code adjustments for steady readings without errors. distance=distance_hi*256+distance_lo Select Case distance Case 0 'SkiperrorsCase20'Skip errors Case <9 hserprint " Distance: "+str(distance)+" mm "; HSerPrintCRLF Case <99 hserprint " Distance: "+str(distance)+" mm "; HSerPrintCRLF Case <999 hserprint " Distance: "+str(distance)+" mm "; HSerPrintCRLF Case <2000 hserprint " Distance: "+str(distance)+" mm "; HSerPrintCRLF Case >2000 'SkipmaximalerrorsEndSelectloop
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#define HI2C_DATA PORTC.5 ;sda portc.4 for nano portc.5 for uno
#define HI2C_CLOCK PORTC.4 ;scl portc.5 for nano portc.4 for uno
#define HI2C_BAUD_RATE 400
HI2CMode Master
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.