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

For general Flowcode discussion that does not belong in the other sections.
Post Reply
KJWILLOTT
Posts: 6
http://meble-kuchenne.info.pl
Joined: Thu Aug 29, 2024 3:49 pm

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

Post 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

medelec35
Matrix Staff
Posts: 1922
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 623 times
Been thanked: 645 times

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

Post 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.
Martin

KJWILLOTT
Posts: 6
Joined: Thu Aug 29, 2024 3:49 pm

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

Post 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

mnfisher
Valued Contributor
Posts: 1462
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

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

Post 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
Attachments
leds.fcfx
(13.56 KiB) Downloaded 9 times

medelec35
Matrix Staff
Posts: 1922
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 623 times
Been thanked: 645 times

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

Post 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.
Attachments
turntable complet no 9-with lights v2.fcfx
(40.28 KiB) Downloaded 2 times
Martin

KJWILLOTT
Posts: 6
Joined: Thu Aug 29, 2024 3:49 pm

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

Post 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

Post Reply