Okay, so i am pretty unexperienced with all this coding stuff but am just looking for a little advice on a small piece of code.
If i have this in the void loop of my code, how can I have it so that it only prints 'k' in serial ONCE everytime x is less than -70?
GamecubePerson111:
Okay, so i am pretty unexperienced with all this coding stuff but am just looking for a little advice on a small piece of code.
If i have this in the void loop of my code, how can I have it so that it only prints 'k' in serial ONCE everytime x is less than -70?
if (x < -70) {
Serial.println('k');
delay(750);
}
Thanks in advance.
You need to look for the signal edge. Assuming x is a signed int, you need to keep track of the last value you checked. If it's now less than -70 and wasn't the last time, then the signal edge occurred, and you can print what you need.
I tried incorporating your method of coding because I need this to happen for several different values, but it seems to still print in serial more than once.