Whenever more than one character is received, Serial.available() >1 will be true.
Since you never read those characters, Serial.available remains >1 hence the functions will execute forever.
What are you trying tho do.
Put { and } on lines by themselves.
Use CTRL T to format your code.
void frank(); this is not the way to call a function, it is a prototype.
.
fileCleaner() got a real good going over, cleanup and rewrite before I realized my mistake. The compiler didn't care that it was in the middle of the code. But it never got called written that way.
fileCleaner() got a real good going over, cleanup and rewrite before I realized my mistake. The compiler didn't care that it was in the middle of the code. But it never got called written that way.
-jim lee
It's also worth remembering that the function "bla" never got called either.
This works and leaves output in Serial Monitor (set it to 250000 baud).
You can enter text over and over and see how it acts, not just go by leds flashing.
I added a loop in setup() since you want to learn more about those.
Be sure to read the comments and ask about what you didn't 'get'.
int frank1 = 8;
int peter1 = 9;
int led3 = 10;
int led4 = 11;
void frank()
{
if (Serial.available()) // not 0 is true
{ // this runs if there's data
char ch = Serial.read(); // read one removes one
// if you don't remove the char it stays available
Serial.print( "Frank " );
Serial.println( ch );
digitalWrite(frank1, HIGH );
delay(300);
digitalWrite(frank1, LOW);
delay(300);
}
}
void peter()
{
if (Serial.available())
{
char ch = Serial.read();
Serial.print( "Peter " );
Serial.println( ch );
digitalWrite(peter1, HIGH);
delay(300);
digitalWrite(peter1, LOW);
delay(300);
}
}
void paul()
{
if (Serial.available())
{
char ch = Serial.read();
Serial.print( "Paul S " );
Serial.println( ch );
digitalWrite(led3, HIGH);
delay(300);
digitalWrite(led3, LOW);
delay(300);
}
}
void bobby()
{
if (Serial.available())
{
char ch = Serial.read();
Serial.print( "Bobby " );
Serial.println( ch );
digitalWrite(led4, HIGH);
delay(300);
digitalWrite(led4, LOW);
delay(300);
}
}
byte countUp; // default is 0
void setup()
{
Serial.begin( 250000); // set Serial Monitor to match
Serial.println( "\nCounting with a LOOP" );
while ( countUp < 10 )
{
Serial.println( countUp );
countUp++; // adds 1 to countUp
}
Serial.println( "\n now enter text from Serial Monitor\n" );
}
void loop()
{ // this brace and the } below BELONG to void loop()
// put right after, it's easier to see that.
frank();
peter();
paul();
bobby();
} // this } is on the same level as the matching {
// that way it is easier to match them up
// it is not "cool" to pack code in ways that make
// it harder to quickly see where one thing begins
// and ends. it's really kind of "fool yourself"
// SMART is making and keeping things clear
void frank(), how is void frank different then void loop plz. my guess at it was it was a loop with a unique name(and maybe timing. thats what i was about to find out) inside
of void loop? Does this mean void loop would also be considered a function?
Jimmylee
Not sure if that game would be helpfull or not. I did look into it as you asked got to the part where it asked for 9.99. you understand.
GoForSmoke
Priceless to me that you did that.
I was down 16hrs just seen all this.
From the looks of it I will be studying for a good stretch just with what has already been provided to me
I mean guys Im still making sure I understand what functions are.