void setup() {
for (int thisPin = 2; thisPin < 10; thisPin++) {
pinMode(thisPin, OUTPUT);
}
Serial.begin(9600);
Serial.println("Serial Initialized.");
}
void loop() {
//test(100);
delay(2000);
String message = "Flash! Message. ";
flashMsg(message);
}
void test(int speed) {
for (int i = 2; i <10; i++){
delay(speed);
digitalWrite(i, HIGH);
delay(speed);
digitalWrite(i, LOW);
}
}
void clearSlate() {
for (int i = 2; i <10; i++){
digitalWrite(i, LOW);
}
}
void flashMsg(String msg) {
Serial.println("Message to print = " + msg);
//Display the binary values
//char firstChar = x[0];
//Serial.print("Now displaying binary value ");
//Serial.print(firstChar, BIN);
//Serial.println();
//Loop to peel off next character
for (int a = 0; a <= msg.length(); a++){
///Serial.print("Peeloff loop iteration " );
//Serial.print(a);
//Serial.println();
char nextChar = msg[a];
Serial.print("Now Printing: " );
Serial.print(nextChar);
Serial.print(" as ");
Serial.print(nextChar, BIN);
Serial.println();
//Loop to display that character on the lights
for (int i = 0; i <= 6; i++) {
//Serial.print("Light loop iteration " );
//Serial.print(i);
//Serial.println();
int thisBit = bitRead(nextChar, i);
//Serial.print("Checking " );
//Serial.print(thisBit);
//Serial.println();
if (thisBit == 1){
//Serial.println("Yes, it's a 1!");
digitalWrite(i+2, HIGH);
}
}
//Serial.println("Done with that character, delay until next...");
delay(300);
clearSlate();
}
}