Étape 4: Arduino Sketch
#include « Wire.h » //libreria para comunicaciones el reloj y el barómetro
#include "Adafruit_MPL115A2.h"// librería barómetro
Adafruit_MPL115A2 mpl115a2 ;
char sensorPrintPress [6] ;
char sensorPrintTemp [5] ;
Declaración de las cadenas de fecha
char dayPrint [3] ;
char monthPrint [3] ;
char yearPrint [5] ;
Declaración de hora de de las cadenas
char hourPrint [3] ;
char minPrint [3] ;
char secPrint [3] ;
Libreria del reloj DS1307
#include « RTClib.h »
RTC_DS1307 CCF ;
taux d’int = 0 ;
Libreria del LCD de Siemens S55
#include « LM15SGFNZ07.h »
LM15SGFNZ07 lcd(2,3,4,5,6) ; config lcd conectivity
void setup()
{
LCD.init_lcd(); / / Inicia la pantalla LCD
LCD.contrast_lcd(0x100) ; réglage du contraste nouveau
LCD.clear_lcd(White); / / Pone la pantalla en blanco
Delay(100) ;
Wire.Begin() ; Inicia el protocolo fil
RTC.begin() ; Inicia el reloj
mpl115a2.Begin (); //Inicia el barómetro
}
void loop()
{
DateTime maintenant = RTC.now (); hora de problemas //Pide el valor
float pressureKPA = 0, temperatureC = 0 ; définir les variables de las del barómetro
pressureKPA = mpl115a2.getPressure (); //lee el valor de la presión
temperatureC = mpl115a2.getTemperature() + 3; //Lee el valor de la temp y Suma tres grados erreur
LCD.str_lcd (« ESTACION METEO », 1, 1, 1, noire, -1) ;
LCD.line_lcd (5, 90, 198, 198, noir) ;
convertir la lecture en chaîne
String sensorP = String(pressureKPA) ;
convertir la lecture en un tableau de char
sensorP.toCharArray (sensorPrintPress, 6) ;
LCD.str_lcd (sensorPrintPress, 8, 3, 1, blanc, blanc) ;
LCD.str_lcd ("Pbaro =", 1, 3, 1, noir, -1) ;
LCD.str_lcd (sensorPrintPress, 8, 3, 1, noir, -1) ;
LCD.str_lcd (« kPa », 15, 3, 1, noir, -1) ;
convertir la lecture en chaîne
String sensorT = String(temperatureC) ;
convertir la lecture en un tableau de char
sensorT.toCharArray (sensorPrintTemp, 5) ;
LCD.str_lcd (sensorPrintTemp, 8, 5, 1, blanc, blanc) ;
LCD.str_lcd ("Temp = «, 1, 5, 1, noir, -1) ;
LCD.str_lcd (sensorPrintTemp, 8, 5, 1, noir, -1) ;
LCD.str_lcd (« C », 13, 5, 1, noire, -1) ;
convertir la lecture en chaîne
LCD.str_lcd ("Fecha =", 1, 7, 1, noir, -1) ;
sday int = now.day() ;
String ssday = String(sday) ;
convertir la lecture en un tableau de char
ssday.toCharArray (dayPrint, 3) ;
LCD.str_lcd (dayPrint, 8, 7, 1, blanc, blanc) ;
LCD.str_lcd (dayPrint, 8, 7, 1, noir, -1) ;
LCD.str_lcd (« / », 10, 7, 1, noir, -1) ;
convertir la lecture en chaîne
int smonth = now.month() ;
String ssmonth = String(smonth) ;
convertir la lecture en un tableau de char
ssmonth.toCharArray (monthPrint, 2) ;
LCD.str_lcd (monthPrint, 11, 7, 1, blanc, blanc) ;
LCD.str_lcd (monthPrint, 11, 7, 1, noir, -1) ;
LCD.str_lcd (« / », 13, 7, 1, noir, -1) ;
convertir la lecture en chaîne
syear int = now.year() ;
String ssyear = String(syear) ;
convertir la lecture en un tableau de char
ssyear.toCharArray (yearPrint, 5) ;
LCD.str_lcd (yearPrint, 14, 7, 1, blanc, blanc) ;
LCD.str_lcd (yearPrint, 14, 7, 1, noir, -1) ;
convertir la lecture en chaîne
LCD.str_lcd (« Hora = ", 1, 9, 1, noir, -1) ;
shour int = now.hour() ;
String sshour = String(shour) ;
convertir la lecture en un tableau de char
sshour.toCharArray (hourPrint, 3) ;
LCD.str_lcd (hourPrint, 7, 9, 1, blanc, blanc) ;
LCD.str_lcd (hourPrint, 7, 9, 1, noir, -1) ;
LCD.str_lcd (« / », 9, 9, 1, noir, -1) ;
convertir la lecture en chaîne
int smin = now.minute() ;
String ssmin = String(smin)
convertir la lecture en un tableau de char
ssmin.toCharArray (minPrint, 3) ;
LCD.str_lcd (minPrint, 10, 9, 1, blanc, blanc) ;
LCD.str_lcd (minPrint, 10, 9, 1, noir, -1) ;
LCD.str_lcd (« / », 12, 9, 1, noir, -1) ;
convertir la lecture en chaîne
ssec int = now.second() ;
String sssec = String(ssec) ;
convertir la lecture en un tableau de char
sssec.toCharArray (secPrint, 3) ;
LCD.str_lcd (secPrint, 13, 9, 1, blanc, blanc) ;
LCD.str_lcd (secPrint, 13, 9, 1, noir, -1) ;
Si {(ssec < 56)
LCD.line_lcd (ssec, 0, 1, 1, bleu) ;
LCD.line_lcd (0, ssec, 2, 2, bleu) ;
LCD.line_lcd (0, ssec, 3, 3, bleu) ;
LCD.line_lcd (0, ssec, 4, 4, bleu) ;
LCD.line_lcd (0, ssec, 5, 5, bleu) ;
}
else {}
LCD.line_lcd (0, 60,1, 1, blanc) ;
LCD.line_lcd (0, 602, 2, blanc) ;
LCD.line_lcd (0, 60,3, 3, blanc) ;
LCD.line_lcd (0, 60,4, 4, blanc) ;
LCD.line_lcd (0, 60,5, 5, blanc) ;
}
Delay(1000) ;
LCD.clear_lcd(White) ;
}