can anyone Explain how to use counter (using example) on this sketch?
so that ..
led off counts from 1-5 times and
led then counts back from 5-1.
thank you
1st time led off = count 1
2nd time led off = count 2
3rd time led off = count 3
4th time led off = count 4
5th time led off = count 5
after count reaches 5
then
each time led is off
1st time led off = count 5
2nd time led off = count 4
3rd time led off = count 3
4th time led off = count 2
5th time led off = count 1
after count reaches 1
then
each time LED is off
1st time led off = count 1
2nd time led off = count 2
3rd time led off = count 3
4th time led off = count 4
5th time led off = count 5
Hi,
The instruction (counter = counter - 1) has to be just after the "led OFF" one. Do not use counter = counter + 1.
What is the counter purpose?.
Regards.
does "count" acts as a predefined arduino function like (pinMode or digitalRead)
and whats the diffence between count and (int i; i++)..are they counts the same..
thanks
lordstark:
thank you for taking the time to reply..
just two quick question?
does "count" acts as a predefined arduino function like (pinMode or digitalRead)
and whats the diffence between count and (int i; i++)..are they counts the same..
thanks
Before asking for further help I'd try to understand, at least, everyone of the lines of the "blink" program. (Understand means "fully" understand).
Regards.
lordstark:
please help me to "fully understand" the problem instead of sending me somewhere else..
im stupid and have zero knowledge about programming.
Hi,
Sorry if the post is a bit rude.
Programming is not an easy task. Maybe it is attracting and funny, but you need some basics to progress.
The forum is not a "teaching service" but a place where you ask for guidance.
If you actually have no idea on programming then the best is to say it from the very beginning ... Frankly it has been such a long time that I cannot recommend a basic programming book. sure there are many tutorials in the Internet: perhaps another forer can give you a better advice.
lordstark:
does "count" acts as a predefined arduino function like (pinMode or digitalRead)
and whats the diffence between count and (int i; i++)..are they counts the same..
thanks
There is no basic function called count, to my knowledge. You make a counter by coding what's above, ie. i++, or i = i + 1, or i = i + variable and controlling it with something like if(condition is true) count up/dn. Substitute a minus sign to decrement.
As mentioned, *count * is just an arbitrary name (identifier) you give to a memory location whose value is incremented/decremented.
You need to be careful that the counter only counts when the stimulus *goes * true - or false if that's your fancy. If your code is such that counting happens *when * the input is true it will count at program scan speed. Probably not what you want.