#ifdef SERIAL_USB
#define SPRN Serial1.print
#define SPLN Serial1.println
#define SERB Serial1.begin
#else
#define SPRN Serial.print
#define SPLN Serial.println
#define SERB Serial.begin
#endif
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin PB1 as an output.
pinMode(PC13, OUTPUT);
SERB(115200);
SPLN("Setup done.");
}
// the loop function runs over and over again forever
void loop() {
SPLN("LIGHT ON");
digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(3000);
SPLN("LIGHT OFF");
digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW
delay(3000);
}
It depends if the LED is PULL up or down to VCC or GND.
“High” on an output pin is always 3.3V, and “Low” is always 0.0V with CMOS 3.3V logic (approximately, it depends on the load).
An LED lights ON with “High” or “Low” – that is based on how the LED is wired:
pin -- resistor -- cathode |<| anode to Vcc LED ON = LOW
pin -- resistor -- anode |>| cathode to Gnd LED ON = HIGH
Oh and the code is from the STM32’s examples which means this part is kind of misleading because it make it sound like it’s just an on/off switch wired to VCC(3.3V):
void loop() {
digitalWrite(PB1, HIGH); // turn the LED on (HIGH is the voltage level) <- misleading part ?
delay(1000); // wait for a second
digitalWrite(PB1, LOW); // turn the LED off by making the voltage LOW <- misleading part ?
delay(1000); // wait for a second
}
Each board can have LED connected in different ways, as Pito mentioned.
On the blue pill, the LED is turned on when LOW is applied.
This is not a bug.
[stevestrong – Thu Jun 07, 2018 11:15 am] –
If you carefully read the example, it is written for the maple mini, which has the LED on PB1 and is turned on when HIGH is applied to the LED.
Each board can have LED connected in different ways, as Pito mentioned.
On the blue pill, the LED is turned on when LOW is applied.
This is not a bug.
That is why I said this:
It can be a WIKI addition like “Some blue pill LEDs are wired the wrong way (don’t post another bug report) “
PS: Btw is it confirmed that it is that way on all Bluepills ? If so it can be added to the Bluepill section of the WiKi as something normal.

- Blue pill led.JPG (19.57 KiB) Viewed 749 times
There is only one BluePill board and it is wired ok.
As I wrote above, different boards may have the LED(s) wired in different way(s).
There are basically 2 ways how to wire an LED (see above).
Thus, with different boards, you have always to double-check, whether LOW or HIGH level lights the LED ON.
A good engineering practice with MCUs is to wire an LED such it lights ON when the pin level is LOW. It is because the pin’s sink current capability is usually higher than its source current capability (it can sink much more current than source).
#ifdef ARDUINO_GENERIC_STM32F103C
#define SPRN Serial1.print
#define SPLN Serial1.println
#define SERB Serial1.begin
#define MYLED PC13
#define LEDON LOW
#define LEDOFF HIGH
#else
#define SPRN Serial.print
#define SPLN Serial.println
#define SERB Serial.begin
#define MYLED 13
#define LEDON HIGH
#define LEDOFF LOW
#endif
FIY, STM32 chips have symmetrical current capability, about +/-8mA (nom.), but this is not the rule, many other chips, for example AT89 has sinking current 1.6mA max and sourcing only -800uA max.

![[SOLVED] Discovery STM32F100RB — Trouble with timers and library structure](https://sparklogic.ru/wp-content/uploads/2019/11/st-stm32vl-discovery-90x90.jpg)
