6376浏览
查看: 6376|回复: 0

[项目] FireBeetle LED_Matrix滚动显示温度

[复制链接]
准备以下物料清单并连接引脚:
数量 名称 ESP32引脚 LED点阵 GOkit2
1 FireBeetle Board-ESP32 3V3 3V3> 3V3
1 FireBeetle Covers - 24×8 LED 点阵屏 GND GND> GND
1 GOkit2 D5> D5
若干 杜邦线 D6> DATA
D7> WR
D8> RD
D9 D3

直接上代码:

[mw_shl_code=cpp,true]#include <stdio.h>
#include <string.h>
#include "DFRobot_HT1632C.h"
#include "DHT.h"

#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

#if defined( ESP_PLATFORM ) || defined( Arduino_ARCH_FIREBEETLE8266 )  //FireBeetle-ESP32 FireBeetle-ESP8266
#define DATA D6
#define CS D5
#define WR D7
//#define RD D8
#else
#define DATA 6
#define CS 5
#define WR 7
//#define RD 8
#endif

DFRobot_HT1632C ht1632c = DFRobot_HT1632C(DATA, WR,CS);

char text[2];

void setup() {
  Serial.begin(115200);
  dht.begin();
  ht1632c.begin();
  ht1632c.isLedOn(true);
  ht1632c.clearScreen();
}

void loop() {
  delay(1000);
  char text2[10] = "temp:";
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  int f = dht.readTemperature(true);
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // Compute heat index in Fahrenheit (the default)
  int hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  int hic = dht.computeHeatIndex(t, h, false);
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print("\n");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print("\n");
  //ht1632c.drawText(strcat(text1, itoa(t, text, 10)), 0, 0, FONT_8X4, FONT_8X4_END, FONT_8X4_HEIGHT);
  //ht1632c.writeScreen();
  ht1632c.print(strcat(text2, itoa(t, text, 10)), 50);
}[/mw_shl_code]


运行效果:
FireBeetle LED_Matrix滚动显示温度图1

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail