Broches Arduino utilisées
A5 to SCL
A4 to SDA
VIN to PWR
GND to GND
*/
int compt0 = 6931; //déclaration du nombre 6931
#include <Wire.h>
#define DISPLAY_ADDRESS1 0x71 //C'est l'adresse par défaut de la OpenSegment avec les deux jumpers ouverts
void setup()
{
Wire.begin(); // Connection au bus I2C en tant que maitre
Wire.beginTransmission(DISPLAY_ADDRESS1); // Débute une transmission sur le bus I2C vers le composant esclave ayant l'adresse indiquée
Wire.write('v'); // envoie la valeur
Wire.endTransmission(); // finalise la transmission
}
void loop()
{
Wire.beginTransmission(DISPLAY_ADDRESS1);
Wire.write(0x7A); // Brightness control command
Wire.write(50); // Set brightness level: 0% to 100%
Wire.endTransmission();
char buffer[4]; // buffer de 4 caractères (Mais ça fonctionne avec 0 et aussi avec un nombre qui a plus de 4 caractères ???)
itoa(compt0,buffer,10); // conversion de compt0 en 4 caractères décimaux
i2cSendString(buffer); //Send the four characters to the display
delay(1000);
}
void i2cSendString(char *toSend) // Envoie les 4 premiers caractères
{
Wire.beginTransmission(DISPLAY_ADDRESS1); // transmit to device #1
for(byte x = 0 ; x < 4 ; x++)
Wire.write(toSend[x]); //Send a character from the array out over I2C
Wire.endTransmission(); //Stop I2C transmission
}
I'm not sure how you expect '6', '9', '3', '1', and NULL to fit in a 4 element array.
I'm not sure what error message you are seeing.
I AM sure that your code doesn't really look like that.
I AM sure that you didn't read the "How to post on this forum" sticky at the top of the forum.