Hi guys,
I'm programming a mechanical 7 segment clock with 4 digits. While testing and debugging my code with one digit, I noticed something strange:
Everything works as anticipated, until I add an extra line of Serial test to display on the computer. I managed to show similar behavior in a more simple example sketch:
#include <Servo.h>
Servo myservo[7]; //Now we have 7 servos
byte seven_seg_digits[2][7] = {
{ 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0 }
};
byte testarray[2][7] = {
{ 1, 2, 3, 4, 5, 6, 7 }, // used for debugging reasons
{ 1, 2, 3, 4, 5, 6, 7 } // used for debugging reasons
};
void setup() {
Serial.begin(9600);
}
void sevenSegWrite(int digit) {
for (int i = 1; i < 8 ; i++) { // attach servos
myservo[i].attach(i + 6);
}
for (int ii = 1; ii < 8 ; ii++) {
myservo[ii].write(90 * seven_seg_digits[digit][ii - 1]); // tell servo to go to position in variable 'pos'
Serial.print("servo "); Serial.print(ii); Serial.print(" - signal "); Serial.println(testarray[1][ii - 1]);
}
}
void loop() {
sevenSegWrite(1); delay(1000);
sevenSegWrite(0); delay(1000);
sevenSegWrite(1); delay(1000);
sevenSegWrite(0); delay(1000000);
}
All servo's move their sweep, until I uncomment the following serial print:
// Serial.print("servo "); Serial.print(ii); Serial.print(" - signal "); Serial.println(testarray[1][ii - 1]);
The last servo, myservo[7] doesn't move anymore. I already tried connecting the last two servo's to pins 5 and 6, but that didn't help.
Who can help me out? For the final program the Serial won't be used anymore, but for testing it's quite nice to now that everything works as anticipated.