Hello everybody,
just read a book about c language and trying to sharpen those newley found skills in practice. (pardon my english becouse it isnt my first language).
So ive put some leds and resistors in series on a "protoboard" and the positive terminals on the pins from 2 to 12 .
Anyway ive been trying to implement a c code in the arduino ide, cuz i dont wanna copy paste digitalWrite etc a million times...So im posting my code here and if anyone can help me where did i go wrong in my c logic.
long long counter = 1000;
int main () {
int ledPin; //maybe i should have picked only one, tried several versions and this logic worked in my head the most
int oldVal;
for( oldVal=2; oldVal <= 12; oldVal++) {
ledPin=oldVal;
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
while(counter < 1000000) { //just a manual delay funct cuz the original one did not work at all
counter++;
}
}
return 0;
}
So basiclly my code for now Works this way;
- Led on the pin2 turns on
- After few seconds all of them(12 of them) turn on simultaneously
I want my code to turn one led on, than wait a certain period of thime than turn the second one, and the third and etc.