VL53LOX con Picaxe 08m2

Gustavo70

Member
Buenos días, me podrían ayudar con el código que debo utilizar para medir distancia con el sensor vl53lox y un Picaxe08m2.
Estoy conectando SDA del sensor en C2 y SCL en C1 del picaxe.
Saludos.
Gustavo
 

Time-Of-Flight VL53L0X PICAXE 08M2+

Original code found in a PICAXE forum based on a PICAXE 14M2. This version of the code slightly modified for a demo with a PICAXE 08M2+. As you get closer to a minimum distance, a LED turns on. Distance is sent to the serial terminal in PE6.

Velleman VL53L0X TIME-OF-FLIGHT (TOF) Ranging and Gesture Detection Sensor VMA337

Tiempo de Vuelo VL53L0X PICAXE 08M2+ [Google Translate]
Código original encontrado en un foro de PICAXE basado en un PICAXE 14M2. Esta versión del código se modificó ligeramente para una demostración con un PICAXE 08M2+. Al acercarse a una distancia mínima, se enciende un LED. La distancia se envía al terminal serie en PE6. Saludos.

PICAXE_08M2_VL53L0X_TOF.jpg

Rich (BB code):
; time-of-flight original code from picaxe forum

; 14m2 vl53l0x demonstration
; i2c interface pin9 sda, pin10 scl

; not much modified for picaxe 08m2+ rhb.20221008
; i2c interface pin5 sda, pin6 scl

init: hi2csetup i2cmaster, 82, i2cfast, i2cbyte

sertxd ("tof test ",cr,lf)

; read product id at 0xc0 to prove i2c working
; should show 238,170,16 (0xee,0xaa,0x10)

hi2cin 0xc0,(b3,b4,b5)
sertxd (#b3," ",#b4," ",#b5,cr,lf)

main: 

    hi2cout 0x00,(0x01) ; start and re-arm

    pause 250
    low c.4

    ; read the range in mm from 0x1e
    hi2cin 0x1e,(b3,b2)
    w2 = b3
    w2 = w2 * 256
    w2 = w2 | b2

    ; only  output when object closer than 150mm
    if w2 > 21 and w2 < 150 then
        sertxd (#time," ",#w2,cr,lf)
        high c.4
    endif

goto main

end
 
Last edited:
Back
Top