Toggle output pin function

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
Post Reply
RGV250
Posts: 264
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 23 times
Been thanked: 30 times

Toggle output pin function

Post by RGV250 »

Hi,
In the software I use for PIC microcontrollers there is a "toggle" function where every cycle the bit inverts which is very useful for an LED in a loop.
I can write it myself but just thought it might be a useful addition to have a toggle bit / output pin option. (If it does not already exist of course)

Regards,
Bob

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: Toggle output pin function

Post by Steve-Matrix »

You can reference port and pin values directly in Flowcode using the "$" symbol, so it is trivial to toggle a pin.

For example, to toggle pin B3, you could either use a calculation icon with the following code:

Code: Select all

$B3 = !$B3

or

$PORTB.3 =  !$PORTB.3
Or alternatively use an Output icon and output the value "!$B3" to pin 3 on PORTB.

Post Reply