Coder Social home page Coder Social logo

vl53l0x-multiple-stm32f103's Introduction

Sử dụng nhiều module Vl53L0X với STM32F1x

Trong code này sử dụng module Bluepill (STM32F103C8T6)

Sử dụng

  1. Khai báo sử dụng I2C trong project

  2. Tạo biến khai báo cảm biến

struct VL53L0X myTOFsensor = {
        .hi2c = &hi2c1, // Kênh I2C sử dụng
        .io_2v8 = true,
        .address = 0x29, // Địa chỉ I2C, mặc định là 0x29
        .io_timeout = 500,
        .did_timeout = false
};
  1. Kích hoạt trong USER CODE BEGIN 2
int main(void) {
    /* USER CODE BEGIN 2 */

    if( VL53L0X_init(&myTOFsensor) ){
        // success - do nothing
    }else{
        // error - Stop
        return 0;
    }

    // Khai báo sử dụng cảm biến ở LONG_RANGE và HIGH_SPEED
    VL53L0X_setSignalRateLimit(&myTOFsensor, 0.1);
	VL53L0X_setVcselPulsePeriod(&myTOFsensor, VcselPeriodPreRange, 18);
	VL53L0X_setVcselPulsePeriod(&myTOFsensor, VcselPeriodFinalRange, 14);
    VL53L0X_setMeasurementTimingBudget(&myTOFsensor, 20000);

    // Khai báo hoạt động ở chế độ đo liên tục
    VL53L0X_startContinuous(&myTOFsensor, 0);

    /* USER CODE END 2 */

    while (1) {
        /* USER CODE BEGIN 3 */

        // Đọc giá trị
        uint16_t value = VL53L0X_readRangeContinuousMillimeters(&myTOFsensor);
        if ( VL53L0X_timeoutOccurred(&myTOFsensor) ) {
            // Đọc lỗi
        }
        
        HAL_Delay(500);

    }
    /* USER CODE END 3 */

vl53l0x-multiple-stm32f103's People

Contributors

nhthai173 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.