本帖最后由 zerostar 于 2021-9-16 00:27 编辑
各位大神好,
刚买了1块ESP32 ,TFT 屏, MAX6635 温度计, 打算造温度纪录器, 但连上后, 2者 都未能运作, 上网看了应该是与 SPI SS/CS 有关,
- #include <SPI.h>
- #include "Adafruit_GFX.h"
- #include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
- #include "max6675.h"
- #define BLACK 0x0000
- #define BLUE 0x001F
- #define RED 0xF800
- #define GREEN 0x07E0
- #define CYAN 0x07FF
- #define YELLOW 0xFFE0
- #define WHITE 0xFFFF
- //TFT setting for NODE32s
- #define TFT_DC 4 // register select (stands for Data Control perhaps!)
- #define TFT_SCLK 18 // SPI clock
- #define TFT_MOSI 23 // SPI Data
- #define TFT_CS 16 // Display enable (Chip select), if not enabled will not talk on SPI bus
- #define TFT_RST 0 // Display reset pin, you can also connect this to the Arduino reset
- Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
- // MAX6625 setting for node32s
- int thermoDO = 19; //MISO
- int thermoCLK = 18;
- int thermoCS1 = 5;
- MAX6675 thermocouple1(thermoCLK, thermoCS1, thermoDO);
- void setup() {
- Serial.begin(9600);
- tft.initR(INITR_BLACKTAB);
- }
- void loop() {
- tft.fillScreen(BLACK);
- tft.setTextColor(BLACK, WHITE);
- tft.setTextSize(1);
- tft.setCursor ( 0, 2);
- delay(2000);
- tft.print ( thermocouple1.readCelsius());
- Serial.print("C = ");
- Serial.println(thermocouple1.readCelsius());
- }
复制代码
有大神可给我建议吗?谢谢
|