Simple clock driver - charAt() not Work - which is of non-class type 'int'

Hi people!

I was making a simple clock. I have 7 led for each digit (I have 4 digit).

I use pin from 2 to 8 for segment controller. And then use A0 to A3 to enable/disable each digit.

From this way first I enable digit 1 and draw the number with Pin 2 to 8.
Next I disable A0 (digit 1) and enable pin A1 to enable digit2, again i use pin 2.8.
the same thing to draw a number in digit 3 and 4.
It run very fast and work fine (Like an old VGA monitor).
From this way I dont need drivers like 74HC595 or any chip.

The problem?
Well I make a function like this: second(dijitSecand1, dijitSecand1);
If the second is in 32, i send it "second(3,2)" and that show in the display, this work fine to.

The problem is how to send the digit separated.
I try to use digitSecond1= second.charAt(1); but give me an error
error: request for member 'charAt' in 'segundos', which is of non-class type 'int'

a simpled the code to explain my problem.

unsigned long startMillis;  //some global variables available anywhere in the program
unsigned long currentMillis;
const unsigned long period = 1000;  //the value is a number of milliseconds


int segundos = 0;



void setup() {
  Serial.begin(9600);    //iniciar puerto serie
  startMillis = millis();  //initial start time
}
 

void loop(){

currentMillis = millis();  //get the current "time" (actually the number of milliseconds since the program started)
  if (currentMillis - startMillis >= period)  //test whether the period has elapsed
  {
    
    if(segundos<9){
    // I can send a zero for the first digit but how can I get the second digit??
    Serial.print(segundos); Serial.print('\n');
    
    }else{
    Serial.print(segundos); Serial.print('\n');
    char mostSignificantDigit = segundos.charAt(1); //This giveme an error
    }
    
    segundos = segundos + 1;
    
    //String test = segundos;
    //char mostSignificantDigit = segundos.charAt(1);
    //aChar = aChar.charAt(1);  
    //Serial.print(mostSignificantDigit);
    //char mostSignificantDigit =segundos.substring(1);
    //Serial.print(segundos); Serial.print('\n');
   
    startMillis = currentMillis;  //IMPORTANT to save the start time of the current LED state.
  }
   
   
}

A picture of the desing (only 2 digit for testing)

charAt() will give you the (ascii code for a) character at a given position in a String ... (and '0' is not the same as the digit 0)

but here you try to call charAt() on an integer... integer don't know how to do this... You need to do math operations. --> if segundos was 32, then segundos / 10 would be 3 and segundos % 10 would be 2.

J-M-L:
charAt() will give you the (ascii code for a) character at a given position in a String ... (and '0' is not the same as the digit 0)

but here you try to call charAt() on an integer... integer don't know how to do this... You need to do math operations. --> if segundos was 32, then segundos / 10 would be 3 and segundos % 10 would be 2.

Thank for the faster answer.

I try to convert to char or String but don´t work.
char second_char = second;
or
String second_char = second;

Do math operations is a cleaver method, thank for that.
but for example 32/10= 3.2 (Int give me only the first digit, that fine.)
How can I get the second digit ("2")?

PD: Sorry now I see the difference between "/" and "%"
This work great!!
Thankyou for Helpmeeee

we would discourage the use of the String class here but you would do something like this:

int segundos  = 32;
String aString = String(segundos);

then you can use the String class methods (functions) on aString

we would favor the use of cStrings (null terminated char arrays) and you could use the itoa() function

int segundos  = 32;
char cString[10]; // need to ensure you have enough space for all the characters
itoa (segundos, cString, 10); // now cString holds three characters '3', then '2' and a trailing null char '\0'