久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 4486|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

基于arduino的VL53L0X模塊的測(cè)速測(cè)距并且在藍(lán)牙和lcd上顯示

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主


單片機(jī)源程序如下:
  1. /* This example shows how to get single-shot range
  2. measurements from the VL53L0X. The sensor can optionally be
  3. configured with different ranging profiles, as described in
  4. the VL53L0X API user manual, to get better performance for
  5. a certain application. This code is based on the four
  6. "SingleRanging" examples in the VL53L0X API.

  7. The range readings are in units of mm. */

  8. /*
  9.   LiquidCrystal Library

  10. Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
  11. library works with all LCD displays that are compatible with the
  12. Hitachi HD44780 driver. There are many of them out there, and you
  13. can usually tell them by the 16-pin interface.

  14. This sketch prints "Hello World!" to the LCD
  15. and shows the time.

  16.   The circuit:
  17. * LCD RS pin to digital pin 12
  18. * LCD Enable pin to digital pin 11
  19. * LCD D4 pin to digital pin 5
  20. * LCD D5 pin to digital pin 4
  21. * LCD D6 pin to digital pin 3
  22. * LCD D7 pin to digital pin 2
  23. * LCD R/W pin to ground
  24. * LCD VSS pin to ground
  25. * LCD VCC pin to 5V
  26. * 10K resistor:
  27. * ends to +5V and ground
  28. * wiper to LCD VO pin (pin 3)

  29. Library originally added 18 Apr 2008
  30. by David A. Mellis
  31. library modified 5 Jul 2009
  32. example added 9 Jul 2009
  33. by Tom Igoe
  34. modified 22 Nov 2010
  35. by Tom Igoe

  36. This example code is in the public domain.

  37. http://www.arduino.cc/en/Tutorial/LiquidCrystal
  38. */

  39. #include <Wire.h>
  40. #include <VL53L0X.h>
  41. #include <LiquidCrystal.h>

  42. #define LED 7

  43. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// initialize the library with the numbers of the interface pins

  44. VL53L0X sensor;

  45. int t = 0;
  46. int spd = 0;
  47. int distance;
  48. int updistance;
  49. /*int rectification;
  50. int rectification1;

  51. //int table[28] = {};  3cm~31cm*/


  52. // Uncomment this line to use long range mode. This
  53. // increases the sensitivity of the sensor and extends its
  54. // potential range, but increases the likelihood of getting
  55. // an inaccurate reading because of reflections from objects
  56. // other than the intended target. It works best in dark
  57. // conditions.

  58. //#define LONG_RANGE


  59. // Uncomment ONE of these two lines to get
  60. // - higher speed at the cost of lower accuracy OR
  61. // - higher accuracy at the cost of lower speed

  62. //#define HIGH_SPEED
  63. #define HIGH_ACCURACY


  64. void setup()
  65. {
  66.   pinMode(LED,OUTPUT);
  67.   Serial.begin(9600);
  68.   Wire.begin();

  69.   sensor.init();
  70.   sensor.setTimeout(500);

  71.    // set up the LCD's number of columns and rows:
  72.   lcd.begin(16, 2);

  73. #if defined LONG_RANGE
  74.   // lower the return signal rate limit (default is 0.25 MCPS)
  75.   sensor.setSignalRateLimit(0.1);
  76.   // increase laser pulse periods (defaults are 14 and 10 PCLKs)
  77.   sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
  78.   sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
  79. #endif

  80. #if defined HIGH_SPEED
  81.   // reduce timing budget to 20 ms (default is about 33 ms)
  82.   sensor.setMeasurementTimingBudget(20000);
  83. #elif defined HIGH_ACCURACY
  84.   // increase timing budget to 200 ms
  85.   sensor.setMeasurementTimingBudget(200000);
  86. #endif


  87.   lcd.clear();//clear lcd
  88.   lcd.setCursor(0, 0);//get location (it is ok outside screen)0-15 inside screen
  89.   lcd.print(" AHU      XIN GE");
  90.   lcd.setCursor(0, 1);//get location (it is ok outside screen)0-15 inside screen
  91.   lcd.print("distance sensor");
  92.   delay(6000);
  93.   
  94. }

  95. void loop()
  96. {


  97.   
  98. //********************************************************************get distance start***************************************************************
  99.   
  100.   updistance = distance;
  101.   distance = sensor.readRangeSingleMillimeters();//get distance
  102. //********************************************************************get distance end********************************************************************


  103. //********************************************************************distance rectify & LED start**************************************************************                                                               
  104.   distance = distance-32;
  105.   if(distance >= 21 && distance <= 55)
  106.   {
  107.      distance = distance* 0.6050 + 13.3228 ;//matlab a = 0.6050    b = 13.3228
  108.      digitalWrite(LED,!digitalRead(LED));
  109.   }
  110.   else if(distance > 55 && distance <= 276)
  111.   {
  112.     distance = distance*1.0312  - 7.2051;//  1.0312   -7.2051
  113.     digitalWrite(LED,LOW);//LED turn off
  114.   }
  115.   else if(distance >= 277 && distance <= 295)
  116.   {
  117.      distance = distance* 1.0436 -8.0835 ;//matlab a = 1.0436  b =   -8.0835
  118.      digitalWrite(LED,!digitalRead(LED));//led twinkle
  119.   }
  120.   else
  121.   {
  122.     digitalWrite(LED,HIGH);//LED turn on
  123.   }
  124.   

  125.   //distance = distance*1.0296 - 6.8681;//matlab a = 1.0296 ,b = -6.8681
  126. //********************************************************************distance rectify & LED end**************************************************************


  127. //********************************************************************show distance start***************************************************************
  128.   lcd.clear();//clear lcd
  129.   lcd.setCursor(0, 0);//get location (it is ok outside screen)0-15 inside screen
  130.   lcd.print("distance:");
  131.   lcd.print(distance);
  132.   lcd.setCursor(14, 0);
  133.   lcd.print("mm");
  134.   
  135.   Serial.print("Distance: ");
  136.   Serial.print(distance);
  137.   Serial.print("mm");
  138.   if (sensor.timeoutOccurred())
  139.   {
  140.     Serial.print(" TIMEOUT");
  141.     lcd.print("TIMEOUT");
  142.   }
  143.   Serial.print("\t");
  144. //********************************************************************show distance end****************************************************************


  145. //********************************************************************show times start***************************************************************
  146.   lcd.setCursor(0, 1);//get location (it is ok outside screen)0-15 inside screen
  147.   lcd.print("T:");
  148.   lcd.print(t);
  149.   
  150.   t++;
  151.   if(t == 1000)
  152.   {
  153.     t = 0;
  154.   }
  155. //********************************************************************show times end***************************************************************


  156. //********************************************************************show speed start***************************************************************
  157.   spd = (updistance - distance)/0.213;
  158.   lcd.setCursor(6, 1);
  159.   lcd.print("V:");
  160.   lcd.print(spd);
  161.   lcd.setCursor(12, 1);
  162.   lcd.print("mm/s");
  163.   Serial.print("  ");
  164.   Serial.print("speed:");
  165.   Serial.print(spd);
  166.   Serial.print("mm/s \n");
  167. //********************************************************************show speed end***************************************************************

  168.   
  169.   
  170. }
復(fù)制代碼

所有資料51hei提供下載:


測(cè)距.zip (97.1 KB, 下載次數(shù): 16)
VL53L0X資料.rar (7.28 MB, 下載次數(shù): 6)


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:363596 發(fā)表于 2018-7-12 01:23 | 只看該作者
* LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 5 * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 * LCD R/W pin to ground * LCD VSS pin to ground * LCD VCC pin to 5V * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3)
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 欧美精品二区 | 天天射视频 | 99在线免费观看 | 岛国av一区二区 | 欧美一级视频免费看 | 亚洲va在线va天堂va狼色在线 | 国产99久久精品一区二区永久免费 | 日本欧美在线视频 | 日韩精品在线网站 | 先锋资源吧 | 福利精品 | www.三级| 亚洲精品国产精品国自产在线 | 成人免费视频网站在线观看 | 国产成人a亚洲精品 | 欧美一区二区久久 | 日韩 国产 在线 | 欧美成人精品一区 | 99一级毛片 | 亚洲成人播放器 | 亚洲91精品 | 国产日韩欧美一区 | 午夜电影日韩 | 狠狠干av| 国产精品99久久久久久久久 | 久久精品这里 | 免费精品 | 日本特黄a级高清免费大片 成年人黄色小视频 | 欧美色专区 | 蜜桃av一区二区三区 | 欧美网站一区二区 | 欧美黑人巨大videos精品 | 精品一区二区三区在线视频 | 午夜播放器在线观看 | 精品一区二区三区在线观看国产 | 久草免费在线视频 | 久久久久国产一区二区三区 | 综合精品 | 天天操天天射综合网 | 久久国产高清视频 | 国产精品18hdxxxⅹ在线 |