Je suis debutant et essai d'afficher sur un affichage I2c 7 segments led le résultat d'un capteur a gas M135., mais je suis coincé, j'arrive a lire sur serial les donnes du capteur, j'arrive a afficher des chiffres sur l'affichage led, mais je n'arrive pas a afficher les résultats du capteur sur l'affichage.
Peut être que quelqu'un a une piste ?
#include <Wire.h>
#include <TM1650.h>
TM1650 d;
int sensorValue;
int digitalValue;
int affiche;
int receiveEvent;
int incomingByte = 0;
void setup()
{
Wire.begin(0x34); // join i2c bus with address #8
Serial.begin(9600); // sets the serial port to 9600
pinMode(2, INPUT);
pinMode(0, INPUT);
d.init();
}
void loop()
{
sensorValue = analogRead(0); // read analog input pin 0
digitalValue = digitalRead(2);
affiche = sensorValue;
Serial.println(sensorValue,DEC); // prints the value read
Serial.println(digitalValue,DEC);
delay(3000); // wait 100ms for next reading
{
d.displayOff();
d.displayString("____");
d.setBrightness(TM1650_MIN_BRIGHT);
d.displayOn();
delay(100);
char line[] = "4321";
d.displayString(line);
d.setBrightnessGradually(TM1650_MAX_BRIGHT);
delay(100);
d.setBrightnessGradually(TM1650_MIN_BRIGHT);
d.displayOff();
delay(100);
d.displayOn();
d.setBrightnessGradually(TM1650_MAX_BRIGHT);
d.displayString(line);
delay(100);
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
//d.displayString('incomingByte');
//delay(2400);
}
}}
Bonsoir Lesept,
merci de ton aide, mais le compilateur renvoit l'erreur suivante :
Arduino : 1.8.5 (Windows 10), Carte : "Arduino/Genuino Uno"
D:\Users\artit\Arduino\sketch_jun14a\sketch_jun14a.ino: In function 'void loop()':
sketch_jun14a:23: error: no matching function for call to 'TM1650::displayString(String)'
d.displayString(String(sensorValue));
^
D:\Users\artit\Arduino\sketch_jun14a\sketch_jun14a.ino:23:38: note: candidate is:
In file included from D:\Users\artit\Arduino\sketch_jun14a\sketch_jun14a.ino:2:0:
D:\Users\artit\Arduino\libraries\TM1650-1.1.0\src/TM1650.h:270:6: note: void TM1650::displayString(char*)
void TM1650::displayString(char *aString)
^
D:\Users\artit\Arduino\libraries\TM1650-1.1.0\src/TM1650.h:270:6: note: no known conversion for argument 1 from 'String' to 'char*'
exit status 1
no matching function for call to 'TM1650::displayString(String)'
Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.
C'est pas normal, le compilo dit qu'il ne trouve pas la fonction displayString dans la biblio TM1650, mais elle existe bien :
void TM1650::displayString(char *aString)
{
if (!iActive) return;
for (int i=0; i<iNumDigits; i++) {
byte a = ((byte) aString[i]) & 0b01111111;
byte dot = ((byte) aString[i]) & 0b10000000;
#ifndef TM1650_USE_PROGMEM
iBuffer[i] = TM1650_CDigits[a];
#else
iBuffer[i] = pgm_read_byte_near(TM1650_CDigits + a);
#endif
if (a) {
Wire.beginTransmission(TM1650_DISPLAY_BASE+i);
Wire.write(iBuffer[i] | dot);
Wire.endTransmission();
}
else
break;
}
}
/** Display string on the display in a running fashion
* aString = character array to be displayed
*
* Starts with first N positions of the string.
* Subsequent characters are displayed with 1 char shift each time displayRunningShift() is called
*
* returns: number of iterations remaining to display the whole string
*/
Elle permet même de faire un affichage déroulant.
Vérifie que tu as bien installé la bibliothèque, au besoin efface la et ré-installe la. Après avoir installé une bibli, il faut relancer 'IDE.