Unable to set PB2 as INPUT_PULLUP on a BlackPill STMF411

Post here first, or if you can't find a relevant section!
Post Reply
raredrop
Posts: 1
Joined: Fri Feb 11, 2022 9:41 pm

Unable to set PB2 as INPUT_PULLUP on a BlackPill STMF411

Post by raredrop »

I'm very new to all of this, so I'm probably missing something obvious.

I'm trying to set PB2 as a pull-up input on a WeAct STM32F411CEU6 BlackPill. The pinMode assignment appears to be ignored and PB2 acts like a pull-down input.

See the below...

Code: Select all

#include <Arduino.h>

void setup(){
    pinMode(PB1, INPUT_PULLUP);
    pinMode(PB2, INPUT_PULLUP);
    
    Serial.begin(115200);
}

void loop(){
    Serial.println("PB1 = " + (String) digitalRead(PB1));
    Serial.println("PB2 = " + (String) digitalRead(PB2));
     
    delay( 1000 );
}
Nothing is connected to either PB1 or PB2. PB1 returns 1, and PB2 returns 0.

Does anyone know why? Is there a way to configure PB2 as a pull-up?

Thanks!
GonzoG
Posts: 492
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: Unable to set PB2 as INPUT_PULLUP on a BlackPill STMF411

Post by GonzoG »

PB2 is pulled down with a 10k resistor.
Post Reply

Return to “General discussion”