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
直接上代码:
#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;
void setup() {
Serial.begin(115200);
dht.begin();
ht1632c.begin();
ht1632c.isLedOn(true);
ht1632c.clearScreen();
}
void loop() {
delay(1000);
char text2 = "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);
}
运行效果:
页:
[1]