Define Macro to toggle a bit of a PIN in C
Given PIN (value) and a bit to be toggled, we have to toggle it using Macro in C language.
To toggle a bit, we use XOR (^) operator.
#define TOGGLE(PIN,N) (PIN ^= (1<<N))
- TOGGLE is the Macro name
- PIN is the value whose bit to be toggled
- N is the bit number