Page 1 of 1

how to turn led on off using +1 counter and -counter

Posted: Sun Mar 09, 2025 6:03 pm
by KJWILLOTT
hello i have led display two counters for counting numbers up and down works ok i would like to turn on four seperate led when the counter increases
i have used 4 decisions in the code each set one higher than the other >=1 >=2 >=3 >=4 this works tried to do the same on the down side when the counter is -1 then i used decision code <=-1 <=-2 <=-3 is their unother way to turn led off using counter -1 can any one help please many thanks

Re: how to turn led on off using +1 counter and -counter

Posted: Sun Mar 09, 2025 10:52 pm
by medelec35
If you post your current project,
We can then help you further.
You also need to state what version of flowcode you are using.

Re: how to turn led on off using +1 counter and -counter

Posted: Wed Mar 19, 2025 7:55 pm
by KJWILLOTT
https://1drv.ms/u/c/8721757fd931cd25/Eb ... Q?e=RDF3x6
This is project how to turn led on off using -1counter and -counter right button increasing count up and turn s 4 leds on each in turn . left button turns counting display down ( problem ) turning 4 led s off in turn using decisions icon and a minus counter
hope you can help many thanks Kevin chart from version flow code v 10 free

Re: how to turn led on off using +1 counter and -counter

Posted: Wed Mar 19, 2025 9:34 pm
by mnfisher
Hi,

Better to attach your chart to the message (Full Editor & preview -> Attachments (below edit window) -> Add files) or drag and drop the file!

There are many ways to do this - I did a very simple demo - that uses an array of LEDs and using consecutive pins (select port mode in properties or set the individual pins)
So - I use the fact that to light the relevant LEDs I can write 2^n-1 to the port (so 0 leds -> 0, 1->1 2->0b11, 3->0b111, and 4->0b1111)

Martin

Re: how to turn led on off using +1 counter and -counter

Posted: Wed Mar 19, 2025 9:40 pm
by medelec35
Hello.
I have edited your post as caps is seen as shounting .
Please don't do that again.
The issue with your project is you used decision branches with negative values e.g If:count >= -2
Count variable is a byte = 0 to 255, so it will never be a negative value.
Therefore all the decision branches with negative values to compare will always be false.
I have modified your project.

Re: how to turn led on off using +1 counter and -counter

Posted: Mon Mar 24, 2025 7:39 pm
by KJWILLOTT
hi martin thank you for your skill and time helping with my project much appreciated did not wish to offend
thank you again for your quick response very helpfull kev