I am having trouble with my code for a counting program. I currently have this:
void setup() {
Serial.begin(9600);
Serial.println("Counting to 10");
Count4Me(10);
}
void loop() {
// put your main code here, to run repeatedly:
}
void Count4Me(int num) {
int i = 1;
while (i <= num) {
Serial.println(i);
i = i + 1;
}
}
This counts to 10 and then stops, which is perfectly working. However, I now want to make it so that when it goes to count it skips or just doesn't print out a certain number on the monitor (for example the number 4).
I have been looking into the reference for the constrain() command and doing research into it, but I am pretty new to all this and still am not quite sure how it works, or whether I am even on the right track.
void setup()
{
Serial.begin(9600);
Serial.println("Counting to 10");
Count4Me(10);
}
void loop()
{
// put your main code here, to run repeatedly:
}
void Count4Me(int num)
{
for (byte i = 1; i <= num; i++)
{
if (i != 4)
{
Serial.println(i);
}
}
}