Go Down

Topic: shield for Arduino Sparkfun DEV-11848 (Read 475 times) previous topic - next topic


I bought a shield for Arduino Sparkfun DEV-11848

I modified an exemplary and I could get the display of a program number.
In my case 3542 :

i2cSendString("3542");  //Send the four characters to the display

Here is my problem:
I would like to display a variable instead of "3542"
This variable has the following format :

volatile int compt=0; // variable de comptage volatile

How to display the value of the variable compt  instead of 3542 ?

Thank you for your help


How to display the value of the variable compt  instead of 3542 ?

Since you need to define what to display as a a string, you need to convert the value to a string. The itoa() function does just that.


Thank you for the reply.

I have other question s:

Should we add a library to the Arduino software ?

I tried to use the itoa instruction without adding library but I have an error message. Maybe I do not have the correct syntax ?

Thank you


Maybe I do not have the correct syntax ?

My crystal ball says you don't.


Ahhhh ça fonctionne
Le programme :



Broches Arduino utilisées
A5 to SCL
A4 to SDA


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.write(0x7A); // Brightness control command
  Wire.write(50); // Set brightness level: 0% to 100%
  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


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++)
  • ); //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.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131