Bonjour à tous et à toutes,
Cela fait maintenant deux jours que je fais quelques manipulations pour m'habituer à mon Arduino Esplora, et aujourd'hui je me suis lancée dans un projet de thermomètre programmable. Le but est d'imposer une limite, modifiable avec les boutons haut et bas, et qui s'affiche sur l'écran.
Cependant, dans la partie affichage de la limite, j'ai un code d'erreur disant "invalid conversion from 'int' to 'const char*' [-fpermissive]".
Je suis plutôt jeune (13 ans), donc même si à force de travail je possède une certaine compréhension du langage Arduino, je suis toujours un peu perdue en ce qui concerne les valeurs char par exemple, que je ne comprends pas bien. Ci-dessous, mon code en entier, l'erreur se trouve aux lignes EsploraTFT.text(limite, 50, 70);
Merci d'avance de votre aide, et si vous en avez le temps, je vous serais reconnaissante de m'expliquer correctement où est l'erreur et comment la réparer, et quel est le rapport avec char.
Bonne journée,
Fenrir
// include the necessary libraries
#include <Esplora.h>
#include <TFT.h> // Arduino LCD library
#include <SPI.h>
char tempPrintoutC[3];
char tempPrintoutF[3]; // array to hold the temperature data
int buttonBas = Esplora.readButton(SWITCH_DOWN);
int buttonHaut = Esplora.readButton(SWITCH_UP);
int limite = 18;
void setup() {
// Put this line at the beginning of every sketch that uses the GLCD
EsploraTFT.begin();
// clear the screen with a black background
EsploraTFT.background(0, 0, 0);
// Pour set les couleurs. Dans l'ordre : Bleu, Vert, Rouge
EsploraTFT.stroke(150, 180, 0);
// set the text to size 2
EsploraTFT.setTextSize(2);
// start the text at the top left of the screen
// this text is going to remain static
// Pour écrire et placer le texte. Dans l'ordre : Texte, Position Horizontale (X), Position Verticale (Y).
EsploraTFT.text("C:\n ", 25, 1);
EsploraTFT.text("F:\n ", 112, 1);
EsploraTFT.stroke(0, 30, 250);
EsploraTFT.text("Limite :\n ", 40, 60);
// set the text in the loop to size 5
EsploraTFT.setTextSize(4);
}
void loop() {
// read the temperature in Celcius and store it in a String
String temperatureC = String(Esplora.readTemperature(DEGREES_C));
String temperatureF = String(Esplora.readTemperature(DEGREES_F));
// convert the string to a char array
temperatureC.toCharArray(tempPrintoutC, 3);
temperatureF.toCharArray(tempPrintoutF, 3);
//Programmation de la limite
if(buttonHaut == LOW)
{
limite++;
}
else {
//Do nothing;
}
if(buttonBas == LOW)
{
limite--;
}
else {
//Do nothing;
}
if (atoi(tempPrintoutC) > limite) {
EsploraTFT.stroke(0, 0, 255);
}
else {
EsploraTFT.stroke(255, 255, 255);
}
int slider = Esplora.readSlider();
if (atoi(tempPrintoutC) > 18) {
// play the note corresponding to the slider's position:
Esplora.tone(slider);
}
else {
Esplora.noTone();
}
// print the temperature one line below the static text
EsploraTFT.text(tempPrintoutC, 12, 25);
EsploraTFT.text(tempPrintoutF, 95, 25);
EsploraTFT.text(limite, 50, 70);
delay(1000);
// erase the text for the next loop
EsploraTFT.stroke(0, 0, 0);
EsploraTFT.text(tempPrintoutC, 12, 25);
EsploraTFT.text(tempPrintoutF, 95, 25);
EsploraTFT.text(limite, 50, 70);
}