oui voilà :
//Bibliothèques
#include <MAX31855.h>
#include <Wire.h>
unsigned char thermocoupleSO = A4; //Thermocouple
unsigned char thermocoupleCS = A5; //Thermocouple
unsigned char thermocoupleCLK = A6; //Thermocouple
int temperature = 0;
volatile word rpmcount; // variable rpmcount
unsigned long rpm; // variable rpm
unsigned long timeold;
MAX31855 MAX31855(thermocoupleSO, thermocoupleCS, thermocoupleCLK); //Thermocouple
void setup(){
Serial.begin(19200); // Initialise la connexion
ELCD_initialize();
delay(200);
ELCD_Clear_LCD();
ELCD_Cursor_OFF;
ELCD_Cursor_Position(0, 0);
ELCD_put_str("temp:");
delay (30);
ELCD_Cursor_Position(0, 1);
ELCD_put_str("Rpm:");
delay (30);
attachInterrupt(0, rpm_fun, RISING);
rpmcount = 0;
rpm = 0;
timeold = 0;
}
void loop(){
// Tachymetre
if (rpmcount >= 100){
rpm = 1000000*60/(micros() - timeold)*rpmcount;
timeold = micros();
rpmcount = 0;
}
String rpm1 = (String(rpm));
ELCD_Cursor_Position(5, 1);
ELCD_put_chr(rpm1.charAt(0));
ELCD_Cursor_Position(6, 1);
ELCD_put_chr(rpm1.charAt(1));
ELCD_Cursor_Position(7, 1);
ELCD_put_chr(rpm1.charAt(2));
ELCD_Cursor_Position(8, 1);
ELCD_put_chr(rpm1.charAt(3));
ELCD_Cursor_Position(9, 1);
ELCD_put_chr(rpm1.charAt(4));
//Thermocouple
temperature = MAX31855.readThermocouple(CELSIUS);
String temp = (String(temperature));
ELCD_Cursor_Position(5, 0);
ELCD_put_chr(temp.charAt(0));
ELCD_Cursor_Position(6, 0);
ELCD_put_chr(temp.charAt(1));
ELCD_Cursor_Position(8, 0);
ELCD_put_chr((char)223);
}
// Fonction RPM
void rpm_fun() {
rpmcount++; //Each rotation, this interrupt function is run twice
}
/* Initialize l'afficheur lcd */
void ELCD_initialize(){
Serial.print(0xA0, BYTE);
}
/* Cache le curseur */
void ELCD_Cursor_OFF(){
Serial.print(0xA3, BYTE);
Serial.print(0x0C, BYTE);
}
/* Affiche le curseur */
void ELCD_Cursor_ON(){
Serial.print(0xA3, BYTE);
Serial.print(0x0E, BYTE);
}
/* Efface l'écran et place le curseur à (0, 0) */
void ELCD_Clear_LCD(){
Serial.print(0xA3, BYTE);
Serial.print(0x01, BYTE);
}
/* Place le curseur à la position (x, y) */
void ELCD_Cursor_Position(int x, int y){
Serial.print(0xA1, BYTE);
Serial.print(x, BYTE);
Serial.print(y, BYTE);
}
/* Affiche une chaine de caractéres (char[] terminé par \0) sur l'afficheur */
void ELCD_put_str(char *str){
Serial.print(0xA2, BYTE);
while(*str)
Serial.print(*str++);
Serial.print(0, BYTE);
}
/* Affiche un caratéres ASCII sur l'afficheur (caractéres spéciaux aux LCD non pris en charge) */
void ELCD_put_chr(char ch){
Serial.print(0xA2, BYTE);
Serial.print(ch);
Serial.print(0, BYTE);
}
/* Définit un caractére personalisé à l'index défini (de 8 à 15) suivant le tableau newChar[],
de structure identique à celui utilisé par la fonction createChar de la lib LiquidCrystal.
Si showAfter = 1 le caractére sera afficher aprés la création, sinon il ne sera afficher qu'aprés un ELCD_put_chr(index) */
void ELCD_create_char(byte index, byte newChar[], byte showAfter) {
if(showAfter)
Serial.print(0xA4, BYTE);
else
Serial.print(0xA5, BYTE);
Serial.print(index, BYTE);
Serial.print(newChar[0] & 0x1F, BYTE);
Serial.print(newChar[1] & 0x1F, BYTE);
Serial.print(newChar[2] & 0x1F, BYTE);
Serial.print(newChar[3] & 0x1F, BYTE);
Serial.print(newChar[4] & 0x1F, BYTE);
Serial.print(newChar[5] & 0x1F, BYTE);
Serial.print(newChar[6] & 0x1F, BYTE);
Serial.print(newChar[7] & 0x1F, BYTE);
}