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
Toggle output pin function
-
- Posts: 283
- http://meble-kuchenne.info.pl
- Joined: Sat Mar 19, 2022 4:53 pm
- Has thanked: 25 times
- Been thanked: 32 times
-
- Matrix Staff
- Posts: 1465
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 204 times
- Been thanked: 347 times
Re: Toggle output pin function
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:
Or alternatively use an Output icon and output the value "!$B3" to pin 3 on PORTB.
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