For statement with serial monitor

So, I am playing with a coin toss sketch where 2 LEDs turn on with a number generator acting like a coin toss. Now I want to count when tails land. I tried an if statement, but it only showed tails as a 1, heads as 0 on the serial. I want it to count up. I have been trying to play with the sketch to get it to increment but no good. My computer is broke so I cannot up load sketch to forum sorry. Looking for an example if possible. I also looked at for statements, but not sure.

Bstanko6:
My computer is broke so I cannot up load sketch to forum sorry.

What you describe is a little hard to understand, seeing what your current code would be very helpful.

Bstanko6:
I also looked at for statements, but not sure.

for statements are loops. How would you use it?

I saw this in for loop and thought it would be for increment ink. I could be wrong. Basically, I just want to count up every time tails lands on serial monitor.

image.jpg

Bstanko6:
I saw this in for loop and thought it would be for increment ink. I could be wrong. Basically, I just want to count up every time tails lands on serial monitor.

For loops are for when you want your code to loop a specified number of times.

Variables are for keeping track of things like, how often something occurs.

int counter=0;  // create a variable
void loop() {
  if (Serial.available()) {  // check to see if a serial character was received.
    if (Serial.read() == '0') {  // see if the user entered "0"
      counter = counter + 1;  // increment the counter variable by 1
     Serial.print("Tails count: "); Serial.println(counter);   // print out current value of counter
    }
   }
}

I'm going to try it. Thank you!