Construcción de Circuito Térmico
0:53
Cpp
#include #include #include #include // Pines para el display ST7789: // Define los pines según tu conexión #define TFT_CS 10 #define TFT_DC 9 #define TFT_RST 8 // Si no tienes pin de reset, podrás conectarlo a RESET // Objeto para el display Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); // Objeto para el sensor AMG8833 Adafruit_AMG88xx amg; // Función que mapea la temperatura a un color uint16_t tempToColor(float temp) { // Mapeo simple: asume rangos entre 20°C y 40°C float norm = (temp - 20.0) / (40.0 - 20.0); if (norm 1.0) norm = 1.0; // Se mapea de azul (frío) a rojo (caliente) uint8_t r = norm * 255; uint8_t g = 0; uint8_t b = (1.0 - norm) * 255; return tft.color565(r, g, b); } void setup() { Serial.begin(9600); // Inicializa el sensor AMG8833 if (!amg.begin()) { Serial.println("No se puede comunicar con el AMG8833."); while (1); } // Inicializa el display ST7789 (tamaño 240x240, ajustar según tu módulo) tft.init(240, 240); tft.fillScreen(ST77XX_BLACK); tft.setRotation(0); delay(100); } void loop() { // Array para almacenar las 64 lecturas (8x8) float pixels[64]; // Lee todos los píxeles del sensor amg.readPixels(pixels); // Determina el tamaño de cada celda en función del tamaño del display int cellWidth = tft.width() / 8; int cellHeight = tft.height() / 8; // Recorre los 8x8 píxeles for (int j = 0; j < 8; j++) { for (int i = 0; i < 8; i++) { int index = i + j * 8; float temp = pixels[index]; // Convierte la temperatura a un color uint16_t color = tempToColor(temp); // Dibuja un rectángulo representando la temperatura tft.fillRect(i * cellWidth, j * cellHeight, cellWidth, cellHeight, color); } } // Espera un segundo antes de actualizar delay(1000); }
tempToColor.Ready.
Reviews
Tight Tomato Heat-Ray
Properties
Properties describe core aspects of the project.
Pricing & Availability
Distributor | Qty 1 |
|---|---|
Arrow | $17.54–$28.44 |
Digi-Key | $18.51–$21.00 |
Mouser | $25.80 |
Verical | $19.34–$28.56 |
Controls
Welcome 👋
Flux helps you build PCBs faster with an AI teammate!
Create your account to collaborate, stay updated, fork your own version, and get instant answers from our AI agent.