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

QQ登錄

只需一步,快速開(kāi)始

搜索

詢問(wèn)Arduino TM1650 4數(shù)碼管模塊能否顯示變量或數(shù)字

查看數(shù): 2398 | 評(píng)論數(shù): 4 | 收藏 1
關(guān)燈 | 提示:支持鍵盤翻頁(yè)<-左 右->
    組圖打開(kāi)中,請(qǐng)稍候......
發(fā)布時(shí)間: 2024-3-29 19:37

正文摘要:

各位好: 我剛開(kāi)始學(xué)習(xí)Arduino, 並多用模塊進(jìn)行練習(xí). 現(xiàn)請(qǐng)問(wèn)一下, TM1650是否只能顯示文字串, 不能顯示數(shù)字? 如果我想顯示數(shù)字的累加或遞減, 如何換為文字串呢? 謝謝! /* 1.  .init();  &nb ...

回復(fù)

ID:884383 發(fā)表于 2024-5-2 21:11
我猜你想描述的是動(dòng)態(tài)顯示數(shù)據(jù)的問(wèn)題,用sprintf函數(shù)即可
ID:69038 發(fā)表于 2024-4-19 09:43
1650本身就是專為數(shù)碼管設(shè)計(jì)的,4位7段或8段,顯示內(nèi)容最多只有4*8點(diǎn),要顯示一個(gè)5*8的點(diǎn)陣都不能完整,你還要顯示字符?或許可以顯示經(jīng)過(guò)變形的LED字體,但你不一定認(rèn)識(shí)顯示的是什么。
如果一定要顯示字符,可以考慮用更多點(diǎn)數(shù)的IC,比如1629,可以顯示8*16點(diǎn),一個(gè)IC可顯示3個(gè)5*8的字符,有余下的點(diǎn),還可以做其它顯示內(nèi)容。
ID:619259 發(fā)表于 2024-4-18 21:54
TM1650是專門為數(shù)碼管設(shè)計(jì)的驅(qū)動(dòng)芯片,一般只是用來(lái)顯示數(shù)字。你說(shuō)的顯示文字串,不明白你是何意
ID:88256 發(fā)表于 2024-3-29 23:13
復(fù)制一個(gè)我從網(wǎng)上下載的程序給你看一下


/*
ESP8266的SoftAP+Web Server配網(wǎng)功能 開(kāi)源帶庫(kù)(帶NTP數(shù)碼管時(shí)鐘)
*/
#include <Wire.h>
#include <ESP8266WebServer.h>
#include <TM1650.h>
#include "Public.h"
#include "WifiConfig.h"
#include "NTP.h"
/*#define SEG_A   0b00000001
#define SEG_B   0b00000010
#define SEG_C   0b00000100
#define SEG_D   0b00001000
#define SEG_E   0b00010000
#define SEG_F   0b00100000
#define SEG_G   0b01000000*/

ESP8266WebServer web(80);   //WEB服務(wù)器,SoftAP默認(rèn)地址為:http://192.168.4.1

#define TM_SCL 5   //GPIO5接TM1637 SCL
#define TM_SDA 13   //GPIO4接TM1637 SDA
TM1650 smg;

//定義特殊字符
//      A
//     ---
//  F |   | B
//     -G-
//  E |   | C
//     ---
//      D
const uint8_t SEG_boot[] =
{   //boot
  SEG_F|SEG_E|SEG_G|SEG_C|SEG_D, SEG_G|SEG_C|SEG_D|SEG_E, SEG_G|SEG_C|SEG_D|SEG_E, SEG_G|SEG_C
};
const uint8_t SEG_Sn[] =
{   //-Sn-
  SEG_G, SEG_A|SEG_F|SEG_G|SEG_C|SEG_D, SEG_E|SEG_G|SEG_C, SEG_G
};
const uint8_t SEG_AP[] =
{   //-AP-
  SEG_G, SEG_A|SEG_B|SEG_C|SEG_E|SEG_F|SEG_G, SEG_A|SEG_B|SEG_E|SEG_F|SEG_G, SEG_G
};

void setup()
{
  //初始化調(diào)試串口
  DebugBegin(74880);   //74880與bootloader的一致,啟動(dòng)時(shí)不會(huì)出現(xiàn)亂碼
  DebugPrintln();   //打印回車換行

  //打印軟件版本信息
  const char BuildDate[]= __DATE__ ;
  const char BuildTime[]= __TIME__ ;
  DebugPrintf("App (Build %s %s) be starting...\n",BuildTime,BuildDate);
  //打印系統(tǒng)及芯片信息
  FlashMode_t ideMode = ESP.getFlashChipMode();
  DebugPrint("Arduino Core For ESP8266 Version: "); DebugPrintln(ESP.getCoreVersion());
  //DebugPrintln(ESP.getFullVersion());
  DebugPrint("Reset reason: "); DebugPrintln(ESP.getResetReason());
  //DebugPrint("Rest info: "); DebugPrintln(ESP.getResetInfo());
  DEBUG_OUTPUT.printf("Chip id: %08X\n", ESP.getChipId());
  DEBUG_OUTPUT.printf("Flash real id: %08X\n", ESP.getFlashChipId());
  DEBUG_OUTPUT.printf("Flash real size: %u KBytes\n", ESP.getFlashChipRealSize()/1024);
  DEBUG_OUTPUT.printf("IDE config Flash size: %u KBytes\n", ESP.getFlashChipSize()/1024);
  DEBUG_OUTPUT.printf("IDE config Flash frequency: %u MHz\n", ESP.getFlashChipSpeed()/1000000);
  DEBUG_OUTPUT.printf("Flash ide mode:  %s\n", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN"));

  //初始化ESP的看門狗
  ESP.wdtEnable(8000);   //使能軟件看門狗的觸發(fā)間隔MS
  ESP.wdtFeed();   //喂狗

  Wire.begin( TM_SDA, TM_SCL );
  smg.Init();
  //時(shí)鐘數(shù)碼管顯示boot
  smg.SetBrightness( 1 );   //設(shè)置亮度
  smg.WriteNum( SEG_boot );   //顯示boot

  //初始化配網(wǎng)功能,SoftAP模式下配網(wǎng):http://192.168.4.1/WifiConfig;程序升級(jí):http://192.168.4.1/update
  WifiConfigInit(&web);

  //主頁(yè)跳轉(zhuǎn),默認(rèn)跳轉(zhuǎn)到配網(wǎng)頁(yè)面
  web.on("/", []()
  {
    web.sendHeader("Location", "/WifiConfig");
    web.send(302, F("text/plain"), "");
  });

  //啟動(dòng)WebServer
  web.begin();
  delay(100);
  web.client().setNoDelay(true);
  DebugPrintln("HTTP server started.");
}

bool Init = true;

void loop()
{
  ESP.wdtFeed();   //喂狗
  WifiConfigTask();   //Wifi配網(wǎng)程序任務(wù)
  web.handleClient();   //WEB服務(wù)處理數(shù)據(jù)

  if(WifiConfigState()==Wifi_AP_OK)
  {   //配網(wǎng)模式下
    smg.SetBrightness( 7 );   //設(shè)置亮度
    smg.WriteNum( SEG_AP );   //顯示-AP-
  }
  if(WifiConfigState()==Wifi_STA_OK)
  {   //聯(lián)網(wǎng)模式下
    if(Init)
    {
      Init=false;
      //在數(shù)碼管上顯示IP地址最后一段,方便瀏覽器輸入地址
      IPAddress myip=WiFi.localIP();
      uint8_t fourth_octet=myip[3];
      uint8_t seg[4];
      seg[0]=SEG_A|SEG_B|SEG_E|SEG_F|SEG_G; //P
      seg[1]=d.encodeDigit(fourth_octet / 100);
      seg[2]=d.encodeDigit(fourth_octet % 100 / 10);
      seg[3]=d.encodeDigit(fourth_octet % 10);
      smg.SetBrightness( 1 );   //設(shè)置亮度
      smg.WriteNum( seg );   //顯示IP地址最后一段
      unsigned long showTime = millis();
      NtpInit(3600);   //初始化NTP功能,每1小時(shí)對(duì)時(shí)一次
      while((millis() - showTime) < 2000) delay(100);   //保證IP可以顯示2s
    }
    else
    {
      task();
    }
  }
  //打印當(dāng)前網(wǎng)絡(luò)狀態(tài)
  if(WifiConfigState()==Wifi_NoLink)DebugPrintln("Wifi config state is Wifi_NoLink");
  if(WifiConfigState()==Wifi_STABegin)DebugPrintln("Wifi config state is Wifi_STABegin");
  if(WifiConfigState()==Wifi_STALinking)DebugPrintln("Wifi config state is Wifi_STALinking");
  //if(WifiConfigState()==Wifi_STA_OK)DebugPrintln("Wifi config state is Wifi_STA_OK");
  if(WifiConfigState()==Wifi_APBegin)DebugPrintln("Wifi config state is Wifi_APBegin");
  //if(WifiConfigState()==Wifi_AP_OK)DebugPrintln("Wifi config state is Wifi_AP_OK");
}

time_t prevDisplay = 0;

void task()
{
  if(timeStatus() == timeNotSet)
  {   //時(shí)間更新失敗
    smg.SetBrightness( 1 );   //設(shè)置亮度
    smg.WriteNum( SEG_Sn );   //顯示-Sn-
  }
  else
  {
    //更新時(shí)間顯示(時(shí)間轉(zhuǎn)換為一個(gè)千位數(shù),冒號(hào)閃爍,保留前導(dǎo)零)
    d.showNumberDecEx(hour()*100+minute(), (millis()%1000<500)?0b01000000:0, true);
    if(now() != prevDisplay)
    {
      prevDisplay = now();
      //這里放只有在時(shí)間發(fā)生變化時(shí)才執(zhí)行的程序(每秒執(zhí)行一次)
      DebugPrintf("%.4u-%.2u-%.2u %.2u:%.2u:%.2u\n", year(), month(), day(), hour(), minute(), second());
      //自動(dòng)亮度調(diào)節(jié)
      if(hour()>6 && hour()<22)
      {   //白天
        smg.SetBrightness( 7 );   //設(shè)置亮度
      }
      else
      {   //晚上
        smg.SetBrightness( 1 );   //設(shè)置亮度
      }
    }
  }
}

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

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

快速回復(fù) 返回頂部 返回列表