Étape 14 : Télécharger le croquis ci-dessous pour obtenir la durée et la température dans votre mini-écran !
Cette esquisse a été modifiée pour exécuter la boucle plus vite... taux de rafraîchissement est d’environ 1,5 secondes.
Copiez le schéma ci-dessous et le coller dans l’IDE Arduino vérifier et exécuter le programme.
cette esquisse a été créée en utilisant le code des adafruit-bibliothèques
#define sclk 4
#define mosi 5
#define cs 6
#define dc 7
#define rst 8
#define ANALOG_IN 3 / / pour les CD capteur de lumière
#include < Adafruit_GFX.h > / / bibliothèque graphique de base
#include < Adafruit_ST7735.h > / / spécifiques au matériel bibliothèque
#include < SPI.h >
#include < Wire.h > / / Bibliothèque nécessaire pour RTC
#include « RTClib.h » //RTC bibliothèque
#include < dht11.h > / / DHT11 temp bibliothèque de capteur d’humidité
RTC_DS1307 CCF ;
dht11 DHT11 ;
Tft Adafruit_ST7735 = Adafruit_ST7735 (cs, dc, mosi, sclk, rst) ;
void setup(void) {}
DHT11.Attach(2) ; définir le port numérique 2 à ressentir DHT11 entrée
Wire.Begin() ;
RTC.begin() ;
tft.initR(INITR_BLACKTAB) ; initialiser un onglet de puce, noire ST7735S
tft.fillScreen(ST7735_BLACK) ;
tftPrintTest() ; Premier texte d’introduction, décommentez pour afficher à l’écran
tft.fillScreen(ST7735_BLACK) ; Efface l’écran
*** Impression éléments statiques exposées dans le programme d’installation Sub afin d’accélérer la boucle vide ***
tft.drawLine (0, 50, tft.width ()-1, 50, ST7735_WHITE) ;
tft.setCursor (0, 60) ;
tft.setTextColor(ST7735_YELLOW) ;
TFT.println ("Temperature (C):") ;
tft.drawLine (0, 110, tft.width ()-1, 110, ST7735_WHITE) ;
tft.setTextColor(ST7735_WHITE) ;
TFT.println ("humidité (%):") ;
tft.setTextColor(ST7735_YELLOW) ;
TFT.println ("température (F):") ;
tft.setTextColor(ST7735_YELLOW) ;
TFT.println ("température (K):") ;
tft.setTextColor(ST7735_WHITE) ;
TFT.println ("Dew Point (C):") ;
tft.setTextColor(ST7735_WHITE) ;
TFT.println("DewPointFast(C):") ;
tft.setCursor(0,115) ;
tft.setTextColor(ST7735_YELLOW) ;
TFT.Print (« intensité lumineuse") ;
}
void loop() {}
tft.setCursor(10,0) ;
tft.setTextColor(ST7735_WHITE) ;
tft.setTextSize(1) ;
TFT.println(" ;
tft.setTextColor(ST7735_YELLOW,ST7735_BLACK) ;
tft.setTextSize(1) ;
tft.setCursor(30,10) ;
DateTime maintenant = RTC.now() ;
TFT.Print(Now.Year(), DEC) ;
TFT.Print('/') ;
TFT.Print(Now.month(), DEC) ;
TFT.Print('/') ;
TFT.Print(Now.Day(), DEC) ;
TFT.println(' ') ;
tft.setCursor(15,25) ;
tft.setTextSize(2) ;
tft.setTextColor(ST7735_BLUE,ST7735_BLACK) ;
TFT.Print(Now.Hour(), DEC) ;
TFT.Print(':') ;
TFT.Print(Now.minute(), DEC) ;
TFT.Print(':') ;
TFT.Print(Now.second(), DEC) ;
TFT.println("") ;
tft.setTextSize(1) ; Définissez la taille du texte à toutes les données venant de DHT11
tft.setCursor (98, 60) ;
tft.setTextColor (ST7735_GREEN, ST7735_BLACK) ; la valeur de couleur pour toutes les données venant de DHT11
TFT.Print((float)DHT11.Temperature,2) ;
tft.setCursor (98, 68) ;
TFT.Print((float)DHT11.Humidity,2) ;
tft.setCursor (98, 76) ;
TFT.Print(DHT11.Fahrenheit(), 2) ;
tft.setCursor (98, 84) ;
TFT.Print(DHT11.Kelvin(), 1) ;
tft.setCursor (98, 92) ;
TFT.Print(DHT11.dewPoint(), 2) ;
tft.setCursor(98,100) ;
TFT.Print(DHT11.dewPointFast(), 2) ;
tft.setCursor(98,115) ;
int val = analogRead(ANALOG_IN) ; VALEUR DE LECTURE CAPTEUR DE LUMIÈRE
tft.setTextColor (ST7735_YELLOW, ST7735_BLACK) ; Définissez la couleur de texte des données capteur de lumière
TFT.Print (val, 1) ; IMPRIMER LA VALEUR DU CAPTEUR DE LUMIÈRE
TFT.Print("") ;
}
void tftPrintTest() {}
tft.setTextWrap(false) ;
tft.fillScreen(ST7735_BLACK) ;
tft.setCursor (0, 10) ;
tft.setTextColor(ST7735_WHITE) ;
tft.setTextSize(1) ;
TFT.println(" ;
Delay(500) ;
tft.setCursor (0, 60) ;
tft.setTextColor(ST7735_RED) ;
tft.setTextSize(2) ;
TFT.println("Temperature") ;
tft.setTextColor(ST7735_YELLOW) ;
tft.setTextSize(2) ;
TFT.println("Humidity") ;
tft.setTextColor(ST7735_GREEN) ;
tft.setTextSize(2) ;
TFT.println("Monitor") ;
tft.setTextColor(ST7735_BLUE) ;
Delay(50) ;
}