A LED can be connected as "Active Low" or as "Active High". This reflects the state (0 or 1) that has to be written to the pin to let the LED light. I use frequently in my code
#define ActiveHigh TRUE // LEDs are active high in this application #define LEDOFF !LEDON #define LEDON ActiveHigh
There are some more components that have different underlying hardware. UDB based components and TCPWM based ones.
An Led can be connected to any MCU in two configurations:
- Active low, as indicated below:
- Active high, as indicated below:
Depending on how the LED is connected, you need to write a "0" to turn ON an active low LED and a "1" to turn ON an active high LED.
Also, GPIO pins of some of the PSoC devices have higher sink current capability than the amount of current that can be sourced from that pin. Thus, it makes sense to connect the LED in active low configuration for such pins and write a "0" to drive the LED ON.
"u" just stands for unsigned. It's just a best practice to add "u" after all unsigned literals. Refer this stack overflow post.
As JoMe_264151 stated, the underlying hardware for the two components is different. Depending on your application and space/hardware that is already used in your project, then you may prefer/choose one over the other.
(UDB is generally more general-purpose from what I've seen)
The 'u' at the end of the 1 and 0 is to designate an unsigned integer; This is a basic programming fundamental: Integer (computer science) - Wikipedia
And as the other replies stated, the 1 and 0 reflect the voltage/current output of the GPIO pin, but the LED itself may be connect to either a ground or power rail on the other side, thus leading to a sink/source of current to turn on the LED.