Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino - tutorijali, pitanja, primjeri i projekti
Evo kako radi.Koliko sam ja razumeo ono sto sam citao niz se zaustavlja kad naidje na nulu,alp je nema ide dalje dok je ne nadje,mada sam ja nesiguran u sebe ali probao sam ovako int pinCount = 8; i deveti je nula gde staje sto mi bilo isto i ovako
int pinCount = sizeof(ledPins)/sizeof(int)-1; gde -1 zaustavi.Neznam koliko sam u pravu ali ovako radi bez greske.



int Pin = 0;
int timer = 200;
int ledPins[] = {5,6,7,8,9,10,11,12,0};

//int pinCount = 8;//----------------------------------------RADI OVAKO
int pinCount = sizeof(ledPins)/sizeof(int)-1;//------------------------------ I OVAKO

void setup() {

for (Pin = 0; Pin < pinCount; Pin++) {
pinMode(ledPins[Pin], OUTPUT); //---------------------------------------[Pin]
delay(1);
}
}

void loop() {

for (Pin = 0; Pin < pinCount; Pin++) {

digitalWrite(ledPins[Pin], HIGH);
delay(timer);

digitalWrite(ledPins[Pin], LOW);

}


for (int Pin = pinCount; Pin > 0; Pin--) {

digitalWrite(ledPins[Pin], HIGH);
delay(timer);

digitalWrite(ledPins[Pin], LOW);


}
}
Reply


Messages In This Thread
RE: Arduino - tutorijali, pitanja, primjeri i projekti - by MILANNN - 08-16-2021, 05:14 PM

Forum Jump:


Users browsing this thread: 43 Guest(s)