Page 1 of 1

Toggle output pin function

Posted: Mon Nov 20, 2023 8:59 am
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

Re: Toggle output pin function

Posted: Mon Nov 20, 2023 9:36 am
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.