o_O
- Indentation.
- Calling a blocking function from an ISR.
- Using the String class.
Some would call that three strikes. I call that a "learning opportunity".
If you'd be interested, here are some things I would suggest. For the first two issues:
String cell = " ";
String ready_string = " ";
int serial_flag = 1;
int voters = 0;
int pti_voters = 0;
int pmln_voters = 0;
int ppp_voters = 0;
int ji_voters = 0;
////////////////////////
void setup()
{
Serial.begin(9600);
Serial.println("1111111111");
}
////////////////////////////////////////////////////////
void loop()
{
if (Serial.available()) {
char x=Serial.read();
if (x=='#') { cell = Serial.readString(); serial_flag=1;}
else if (x=='
Notice that the timer interrupt is not required. loop just runsrunsruns until the user types something. And you're not blocking inside the timer ISR.
Also notice the readability. Proper indentation makes it very easy to read. When you want help, or when you are looking for a bug, nothing is more important than READABILITY.
Next, try using a switch statement instead of a mess o' ifs:
String cell = " ";
String ready_string = " ";
int serial_flag = 1;
int voters = 0;
int pti_voters = 0;
int pmln_voters = 0;
int ppp_voters = 0;
int ji_voters = 0;
////////////////////////
void setup()
{
Serial.begin(9600);
Serial.println("1111111111");
}
////////////////////////////////////////////////////////
void loop()
{
if (Serial.available()) {
char x=Serial.read();
switch (x) {
case '#': cell = Serial.readString(); serial_flag=1; break;
case '
And finally, quit using the String class, for a multitude of reasons:
char cell[16];
char ready_string[10];
int serial_flag = 1;
int voters = 0;
int pti_voters = 0;
int pmln_voters = 0;
int ppp_voters = 0;
int ji_voters = 0;
////////////////////////
void readStr( char str[], size_t maxchars )
{
size_t length = Serial.readBytes( str, maxchars-1 );
str[ length ] = '\0'; // NUL-terminate the char array
}
////////////////////////
void skipCommand()
{
unsigned long startTime = millis();
do {
while (Serial.available())
Serial.read();
} while (millis() - startTime < 1000);
}
////////////////////////
void setup()
{
Serial.begin(9600);
Serial.println("1111111111");
}
////////////////////////
void loop()
{
if (Serial.available()) {
char x=Serial.read();
switch (x) {
case '#':
readStr( cell, sizeof(cell) );
serial_flag=1;
break;
case '
Notice that the program size has dropped to 3354 bytes from 5088 bytes, a savings of 1734 bytes. And your street cred has gone up, too. 
The next thing you should look at is Robin2's Serial Input Basics, reachable from the very Useful Links page. Your current program "blocks" to read a command. Until the entire line is received, nothing else in your sketch will be executed.
Serial Input Basics has several examples that show how you can keep loop runrunrunning while the command is being accumulated. When the newline finally shows up, milliseconds later, you can parse the command all at once. Then your program will be able to execute all the other things it needs to do at the "same" time.
Cheers,
/dev) { ready_string= Serial.readString(); serial_flag=2;}
else if (x=='*') { voters = Serial.parseInt (); serial_flag=3;}
else if (x=='!') { pti_voters = Serial.parseInt (); serial_flag=4;}
else if (x=='@') { pmln_voters = Serial.parseInt (); serial_flag=5;}
else if (x=='<') { ppp_voters = Serial.parseInt (); serial_flag=6;}
else if (x=='>') { ji_voters = Serial.parseInt (); serial_flag=7;}
else { String abc = Serial.readString(); serial_flag=0;}
}
if (serial_flag!=0) {
if (serial_flag==1) Serial.print ( cell );
else if (serial_flag==2) Serial.print ( ready_string );
else if (serial_flag==3) Serial.println( voters );
else if (serial_flag==4) Serial.println( pti_voters );
else if (serial_flag==5) Serial.println( pmln_voters );
else if (serial_flag==6) Serial.println( ppp_voters );
else if (serial_flag==7) Serial.println( ji_voters );
serial_flag=0;
}
}
Notice that the timer interrupt is not required. **loop** just runsrunsruns until the user types something. And you're not blocking inside the timer ISR.
Also notice the readability. Proper indentation makes it very easy to read. When you want help, or when you are looking for a bug, nothing is more important than READABILITY.
Next, try using a **switch** statement instead of a mess o' **if**s:
§DISCOURSE_HOISTED_CODE_1§
And finally, quit using the **String** class, for a [multitude](http://forum.arduino.cc/index.php?topic=382944.msg2640860#msg2640860) [of](http://forum.arduino.cc/index.php?topic=396099.msg2726746#msg2726746) [reasons](http://forum.arduino.cc/index.php?topic=385867.msg2661171#msg2661171):
§DISCOURSE_HOISTED_CODE_2§
Notice that the program size has dropped to 3354 bytes from 5088 bytes, a savings of 1734 bytes. And your street cred has gone up, too. ;)
The next thing you should look at is Robin2's **Serial Input Basics**, reachable from the very [Useful Links](http://forum.arduino.cc/index.php?topic=384198.0) page. Your current program "blocks" to read a command. Until the entire line is received, nothing else in your sketch will be executed.
**Serial Input Basics** has several examples that show how you can keep **loop** runrunrunning while the command is being accumulated. When the newline finally shows up, milliseconds later, you can parse the command all at once. Then your program will be able to execute all the other things it needs to do at the "same" time.
Cheers,
/dev: ready_string= Serial.readString(); serial_flag=2; break;
case '*': voters = Serial.parseInt (); serial_flag=3; break;
case '!': pti_voters = Serial.parseInt (); serial_flag=4; break;
case '@': pmln_voters = Serial.parseInt (); serial_flag=5; break;
case '<': ppp_voters = Serial.parseInt (); serial_flag=6; break;
case '>': ji_voters = Serial.parseInt (); serial_flag=7; break;
default : Serial.readString(); serial_flag=0; break;
}
}
if (serial_flag!=0) {
switch (serial_flag) {
case 1: Serial.print ( cell ); break;
case 2: Serial.print ( ready_string ); break;
case 3: Serial.println( voters ); break;
case 4: Serial.println( pti_voters ); break;
case 5: Serial.println( pmln_voters ); break;
case 6: Serial.println( ppp_voters ); break;
case 7: Serial.println( ji_voters ); break;
}
serial_flag=0;
}
}
And finally, quit using the String class, for a multitude of reasons:
§_DISCOURSE_HOISTED_CODE_2_§
Notice that the program size has dropped to 3354 bytes from 5088 bytes, a savings of 1734 bytes. And your street cred has gone up, too. 
The next thing you should look at is Robin2's Serial Input Basics, reachable from the very Useful Links page. Your current program "blocks" to read a command. Until the entire line is received, nothing else in your sketch will be executed.
Serial Input Basics has several examples that show how you can keep loop runrunrunning while the command is being accumulated. When the newline finally shows up, milliseconds later, you can parse the command all at once. Then your program will be able to execute all the other things it needs to do at the "same" time.
Cheers,
/dev) { ready_string= Serial.readString(); serial_flag=2;}
else if (x=='*') { voters = Serial.parseInt (); serial_flag=3;}
else if (x=='!') { pti_voters = Serial.parseInt (); serial_flag=4;}
else if (x=='@') { pmln_voters = Serial.parseInt (); serial_flag=5;}
else if (x=='<') { ppp_voters = Serial.parseInt (); serial_flag=6;}
else if (x=='>') { ji_voters = Serial.parseInt (); serial_flag=7;}
else { String abc = Serial.readString(); serial_flag=0;}
}
if (serial_flag!=0) {
if (serial_flag==1) Serial.print ( cell );
else if (serial_flag==2) Serial.print ( ready_string );
else if (serial_flag==3) Serial.println( voters );
else if (serial_flag==4) Serial.println( pti_voters );
else if (serial_flag==5) Serial.println( pmln_voters );
else if (serial_flag==6) Serial.println( ppp_voters );
else if (serial_flag==7) Serial.println( ji_voters );
serial_flag=0;
}
}
Notice that the timer interrupt is not required. **loop** just runsrunsruns until the user types something. And you're not blocking inside the timer ISR.
Also notice the readability. Proper indentation makes it very easy to read. When you want help, or when you are looking for a bug, nothing is more important than READABILITY.
Next, try using a **switch** statement instead of a mess o' **if**s:
§DISCOURSE_HOISTED_CODE_1§
And finally, quit using the **String** class, for a [multitude](http://forum.arduino.cc/index.php?topic=382944.msg2640860#msg2640860) [of](http://forum.arduino.cc/index.php?topic=396099.msg2726746#msg2726746) [reasons](http://forum.arduino.cc/index.php?topic=385867.msg2661171#msg2661171):
§DISCOURSE_HOISTED_CODE_2§
Notice that the program size has dropped to 3354 bytes from 5088 bytes, a savings of 1734 bytes. And your street cred has gone up, too. ;)
The next thing you should look at is Robin2's **Serial Input Basics**, reachable from the very [Useful Links](http://forum.arduino.cc/index.php?topic=384198.0) page. Your current program "blocks" to read a command. Until the entire line is received, nothing else in your sketch will be executed.
**Serial Input Basics** has several examples that show how you can keep **loop** runrunrunning while the command is being accumulated. When the newline finally shows up, milliseconds later, you can parse the command all at once. Then your program will be able to execute all the other things it needs to do at the "same" time.
Cheers,
/dev:
readStr( ready_string, sizeof(ready_string) );
serial_flag=2;
break;
case '*': voters = Serial.parseInt(); serial_flag=3; break;
case '!': pti_voters = Serial.parseInt(); serial_flag=4; break;
case '@': pmln_voters = Serial.parseInt(); serial_flag=5; break;
case '<': ppp_voters = Serial.parseInt(); serial_flag=6; break;
case '>': ji_voters = Serial.parseInt(); serial_flag=7; break;
default : skipCommand (); serial_flag=0; break;
}
}
if (serial_flag!=0) {
switch (serial_flag) {
case 1: Serial.print ( cell ); break;
case 2: Serial.print ( ready_string ); break;
case 3: Serial.println( voters ); break;
case 4: Serial.println( pti_voters ); break;
case 5: Serial.println( pmln_voters ); break;
case 6: Serial.println( ppp_voters ); break;
case 7: Serial.println( ji_voters ); break;
}
serial_flag=0;
}
}
Notice that the program size has dropped to 3354 bytes from 5088 bytes, a savings of 1734 bytes. And your street cred has gone up, too. 
The next thing you should look at is Robin2's Serial Input Basics, reachable from the very Useful Links page. Your current program "blocks" to read a command. Until the entire line is received, nothing else in your sketch will be executed.
Serial Input Basics has several examples that show how you can keep loop runrunrunning while the command is being accumulated. When the newline finally shows up, milliseconds later, you can parse the command all at once. Then your program will be able to execute all the other things it needs to do at the "same" time.
Cheers,
/dev) { ready_string= Serial.readString(); serial_flag=2;}
else if (x=='*') { voters = Serial.parseInt (); serial_flag=3;}
else if (x=='!') { pti_voters = Serial.parseInt (); serial_flag=4;}
else if (x=='@') { pmln_voters = Serial.parseInt (); serial_flag=5;}
else if (x=='<') { ppp_voters = Serial.parseInt (); serial_flag=6;}
else if (x=='>') { ji_voters = Serial.parseInt (); serial_flag=7;}
else { String abc = Serial.readString(); serial_flag=0;}
}
if (serial_flag!=0) {
if (serial_flag==1) Serial.print ( cell );
else if (serial_flag==2) Serial.print ( ready_string );
else if (serial_flag==3) Serial.println( voters );
else if (serial_flag==4) Serial.println( pti_voters );
else if (serial_flag==5) Serial.println( pmln_voters );
else if (serial_flag==6) Serial.println( ppp_voters );
else if (serial_flag==7) Serial.println( ji_voters );
serial_flag=0;
}
}
Notice that the timer interrupt is not required. **loop** just runsrunsruns until the user types something. And you're not blocking inside the timer ISR.
Also notice the readability. Proper indentation makes it very easy to read. When you want help, or when you are looking for a bug, nothing is more important than READABILITY.
Next, try using a **switch** statement instead of a mess o' **if**s:
§DISCOURSE_HOISTED_CODE_1§
And finally, quit using the **String** class, for a [multitude](http://forum.arduino.cc/index.php?topic=382944.msg2640860#msg2640860) [of](http://forum.arduino.cc/index.php?topic=396099.msg2726746#msg2726746) [reasons](http://forum.arduino.cc/index.php?topic=385867.msg2661171#msg2661171):
§DISCOURSE_HOISTED_CODE_2§
Notice that the program size has dropped to 3354 bytes from 5088 bytes, a savings of 1734 bytes. And your street cred has gone up, too. ;)
The next thing you should look at is Robin2's **Serial Input Basics**, reachable from the very [Useful Links](http://forum.arduino.cc/index.php?topic=384198.0) page. Your current program "blocks" to read a command. Until the entire line is received, nothing else in your sketch will be executed.
**Serial Input Basics** has several examples that show how you can keep **loop** runrunrunning while the command is being accumulated. When the newline finally shows up, milliseconds later, you can parse the command all at once. Then your program will be able to execute all the other things it needs to do at the "same" time.
Cheers,
/dev: ready_string= Serial.readString(); serial_flag=2; break;
case '*': voters = Serial.parseInt (); serial_flag=3; break;
case '!': pti_voters = Serial.parseInt (); serial_flag=4; break;
case '@': pmln_voters = Serial.parseInt (); serial_flag=5; break;
case '<': ppp_voters = Serial.parseInt (); serial_flag=6; break;
case '>': ji_voters = Serial.parseInt (); serial_flag=7; break;
default : Serial.readString(); serial_flag=0; break;
}
}
if (serial_flag!=0) {
switch (serial_flag) {
case 1: Serial.print ( cell ); break;
case 2: Serial.print ( ready_string ); break;
case 3: Serial.println( voters ); break;
case 4: Serial.println( pti_voters ); break;
case 5: Serial.println( pmln_voters ); break;
case 6: Serial.println( ppp_voters ); break;
case 7: Serial.println( ji_voters ); break;
}
serial_flag=0;
}
}
And finally, quit using the String class, for a multitude of reasons:
§_DISCOURSE_HOISTED_CODE_2_§
Notice that the program size has dropped to 3354 bytes from 5088 bytes, a savings of 1734 bytes. And your street cred has gone up, too. 
The next thing you should look at is Robin2's Serial Input Basics, reachable from the very Useful Links page. Your current program "blocks" to read a command. Until the entire line is received, nothing else in your sketch will be executed.
Serial Input Basics has several examples that show how you can keep loop runrunrunning while the command is being accumulated. When the newline finally shows up, milliseconds later, you can parse the command all at once. Then your program will be able to execute all the other things it needs to do at the "same" time.
Cheers,
/dev) { ready_string= Serial.readString(); serial_flag=2;}
else if (x=='*') { voters = Serial.parseInt (); serial_flag=3;}
else if (x=='!') { pti_voters = Serial.parseInt (); serial_flag=4;}
else if (x=='@') { pmln_voters = Serial.parseInt (); serial_flag=5;}
else if (x=='<') { ppp_voters = Serial.parseInt (); serial_flag=6;}
else if (x=='>') { ji_voters = Serial.parseInt (); serial_flag=7;}
else { String abc = Serial.readString(); serial_flag=0;}
}
if (serial_flag!=0) {
if (serial_flag==1) Serial.print ( cell );
else if (serial_flag==2) Serial.print ( ready_string );
else if (serial_flag==3) Serial.println( voters );
else if (serial_flag==4) Serial.println( pti_voters );
else if (serial_flag==5) Serial.println( pmln_voters );
else if (serial_flag==6) Serial.println( ppp_voters );
else if (serial_flag==7) Serial.println( ji_voters );
serial_flag=0;
}
}
Notice that the timer interrupt is not required. **loop** just runsrunsruns until the user types something. And you're not blocking inside the timer ISR.
Also notice the readability. Proper indentation makes it very easy to read. When you want help, or when you are looking for a bug, nothing is more important than READABILITY.
Next, try using a **switch** statement instead of a mess o' **if**s:
§DISCOURSE_HOISTED_CODE_1§
And finally, quit using the **String** class, for a [multitude](http://forum.arduino.cc/index.php?topic=382944.msg2640860#msg2640860) [of](http://forum.arduino.cc/index.php?topic=396099.msg2726746#msg2726746) [reasons](http://forum.arduino.cc/index.php?topic=385867.msg2661171#msg2661171):
§DISCOURSE_HOISTED_CODE_2§
Notice that the program size has dropped to 3354 bytes from 5088 bytes, a savings of 1734 bytes. And your street cred has gone up, too. ;)
The next thing you should look at is Robin2's **Serial Input Basics**, reachable from the very [Useful Links](http://forum.arduino.cc/index.php?topic=384198.0) page. Your current program "blocks" to read a command. Until the entire line is received, nothing else in your sketch will be executed.
**Serial Input Basics** has several examples that show how you can keep **loop** runrunrunning while the command is being accumulated. When the newline finally shows up, milliseconds later, you can parse the command all at once. Then your program will be able to execute all the other things it needs to do at the "same" time.
Cheers,
/dev