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)