欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: Arduino 10kg電子秤程序(hx711+oled12864屏幕) [打印本頁]

作者: ytmingg    時(shí)間: 2020-9-17 22:24
標(biāo)題: Arduino 10kg電子秤程序(hx711+oled12864屏幕)
本帖最后由 ytmingg 于 2020-9-17 22:41 編輯



Arduino 10kg電子秤程序(hx711+oled12864屏幕)





1.程序

#include <HX711.h>
#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[0] )
int Weight = 0;
char str[4];  //定義重量值存儲數(shù)組,5位,其中4位為數(shù)字,1位為小數(shù)點(diǎn)
int temp =0;  //定義重量值中間變量,,用于將獲取的float型重量值轉(zhuǎn)變?yōu)閡nsigned char數(shù)組

void draw(void) {

  u8g.setFont(u8g_font_8x13); //使用8x13大小的字符
  u8g.setPrintPos(0, 20); // 對應(yīng) x,y 軸值
  u8g.print(" weight:");
  u8g.setPrintPos(60, 50);
  u8g.print(Weight);
  u8g.setPrintPos(100, 50); // 對應(yīng) x,y 軸值
  u8g.print("g");
}

void setup() {
Serial.begin(9600);
Init_Hx711();//初始化HX711模塊連接的IO設(shè)置
Get_Maopi(); //獲取毛皮
delay(200);
Get_Maopi(); //獲取毛皮
}

void loop()
{
    Weight = Get_Weight();//計(jì)算放在傳感器上的重物重量
    temp =Get_Weight();
    if(temp<0){  temp =0; }
    dtostrf(temp,4,0,str);
    Serial.print("W="); //串口顯示重量
    Serial.print(Weight);        //串口顯示重量
    Serial.print(" g\n");        //顯示單位
  delay(200);

u8g.firstPage();
  do
  {
    draw();
  }
  while ( u8g.nextPage() );
}




2.附件

10kg.zip (999 Bytes, 下載次數(shù): 31)

U8glib.zip (1.01 MB, 下載次數(shù): 28)

10kg.zip (999 Bytes, 下載次數(shù): 21)












作者: shouji6406    時(shí)間: 2020-9-20 17:08
學(xué)習(xí)學(xué)習(xí),感謝源碼分享




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1