Why do I need this?
why do I need to use the "int" again on counterLED below void loop, if I had already used it in void setup? It says that counterLED wasnt enabled in this scope, but I thought the int counterLED inside the for loop at void setup would have done the job.
I fattened the code that Im trying to understand.
The code:
int counter;
int delay1 = 666;
void setup() {
* this is the first time is use int*
for(int counterLED=2;counterLED<=6;counterLED++) {
pinMode(counterLED, OUTPUT);
}
Serial.begin(9600);
}
void loop() {
* why is the int needed here again for the same variable?*
for (int counterLED=2; counterLED<=6;counterLED++) {
digitalWrite(counterLED, HIGH);
delay(delay1);
digitalWrite(counterLED, LOW);
}
thanks a lot
22 Replies
@TheStudier do you have a local grocery store near you?
yes
a ffew
I have one near me also.
im gonna go to one of them in the morning prolly
at 6 am
If I told you now. Go to the local grocery store and I will meat you there in 5 minutes. And I went to mine.. do you think we would meet?
no
Why
i dont know what store you talking about
The local grocery store
i dont know where you live
The local grocery store
yes maybe by luck we could meet
But there is no garentee right?
indeed
Bingo.
When you make a varable INSIDE a function its called a LOCAL varable
That is it only exists INSIDE that one varable.
do you mean it exists inside that one function instead of variable?
"That is it only exists INSIDE that one varable"
No that VARABLE only exist inside that one FUNCTION
yes
i thougt you said varable exists in varable sorry
Just like your physical store only exist in your town and mine in my town.
So if you try and access it OUTSIDE of that function say frome loop... it does NOT exist. So you need to make it again.
so
the code in the void setup says "pinMode(counterLED, OUTPUT);
wait
nothing
I think I understand
nice
Ha ha
I no it sounds like im talking crazy.. but if you hang with me. You will get smarter and learn yhings.
okay thanks a lot this was a huge helper, also, your profile says "everything is IMO" In my opinion it should say "everyting is IMO, IMO"