O
orvtech
Guest
Friends,
I apologize for this noobish question, I have over 15 years without doing any C programing what so ever.
I am trying to get a counter going in this script but it seems that it doesn't increment past 1. Any ideas what might be going on?
I apologize for this noobish question, I have over 15 years without doing any C programing what so ever.
I am trying to get a counter going in this script but it seems that it doesn't increment past 1. Any ideas what might be going on?
Code:
const int ledPin = 13; // choose the pin for the LED
int counter = 0;
char pin[4];
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
Serial.begin(9600);
while (!Serial) {}
}
void working(){
if (counter <= 9999){
digitalWrite(ledPin, LOW);
delay(5000);
digitalWrite(ledPin, HIGH);
sprintf(pin, "%04d", counter);
Serial.println(pin);
}
if (counter > 9999){
digitalWrite(ledPin, LOW);
delay(1000);
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
digitalWrite(ledPin, HIGH);
delay(10000);
}
++counter;
//Keyboard.print(pin);
//Keyboard.print(counter);
}
void loop(){
working();
}
Last edited: