Problem in output. 7 segment single digit display. NEED HELP!

I thought you wanted to display the value of the last character received on the seven segment display?

at the first writing I print the first number in loop turning on only one led at a time until i type the second, later when I give the following number in input it will print the second number in the same way as the first, then I type the third and so on.
I don't know if i explained it clear

At the end of the code that lights up the segments one by one, you need to put the original code that lights all the segments for the character without the delays.

oh now it works. Thanks man, but i don't understand why it works. Can you explain it to me?

I can't see what you have done ...

(Remember the code tags)

#include <EEPROM.h>

const int A=7;
const int B=6;
const int C=4;
const int D=2;
const int E=11;
const int F=9;
const int G=10;
int x=0;
int n=0;
void setup() {
 pinMode (A,OUTPUT);
 pinMode (B,OUTPUT);
 pinMode (C,OUTPUT);
 pinMode (D,OUTPUT);
 pinMode (E,OUTPUT);
 pinMode (F,OUTPUT);
 pinMode (G,OUTPUT);

Serial.begin(9600);

EEPROM.write(0,63);
EEPROM.write(1,6);
EEPROM.write(2,91);
EEPROM.write(3,79);
EEPROM.write(4,102);
EEPROM.write(5,109);
EEPROM.write(6,125);
EEPROM.write(7,7);
EEPROM.write(8,127);
EEPROM.write(9,103);


}

void loop() {
  if (Serial.available() > 0) {   
      n=Serial.read()-48;
      x=EEPROM.read(n);
      digitalWrite(A,bitRead(x,0));
      delay(100);
      digitalWrite(A,LOW);
      digitalWrite(B,bitRead(x,1));
      delay(100);
      digitalWrite(B,LOW);
      digitalWrite(C,bitRead(x,2));
      delay(100);
      digitalWrite(C,LOW);
      digitalWrite(D,bitRead(x,3));
      delay(100);
      digitalWrite(D,LOW);
      digitalWrite(E,bitRead(x,4));
      delay(100);
      digitalWrite(E,LOW);
      digitalWrite(F,bitRead(x,5));
      delay(100);
      digitalWrite(F,LOW);
      digitalWrite(G,bitRead(x,6));
      delay(100);
      digitalWrite(G,LOW);
   }
      digitalWrite(A,bitRead(x,0));
      delay(100);
      digitalWrite(A,LOW);
      digitalWrite(B,bitRead(x,1));
      delay(100);
      digitalWrite(B,LOW);
      digitalWrite(C,bitRead(x,2));
      delay(100);
      digitalWrite(C,LOW);
      digitalWrite(D,bitRead(x,3));
      delay(100);
      digitalWrite(D,LOW);
      digitalWrite(E,bitRead(x,4));
      delay(100);
      digitalWrite(E,LOW);
      digitalWrite(F,bitRead(x,5));
      delay(100);
      digitalWrite(F,LOW);
      digitalWrite(G,bitRead(x,6));
      delay(100);
      digitalWrite(G,LOW);
}

Well, I'd 've put the new code inside the condition but that's fine.

What don't you understand about it?
Both x and n retain their values until a new character is read because they have global scope.

ahh alright yes because is a loop function ahah. there is a way to write it shorter?

Wait - how is it working if you turn the segments off as soon as they're lit?

yeah sorry ahah, i flip that and it works i copyied the wrong one.

corrected.

can you explain me the concept and what means Seria.read()? because i found that on internet but i don't understand properly how it works.

Serial.read returns an int.
If there was a character that had been received from the serial port and buffered, then the value of that character is returned, otherwise -1 is returned
Because you use Serial.available, this checks to see if there are any characters ready to be read, so you never see -1.

ahhh now i undestand! thank you :slight_smile: