I
I
iDraeam94i2018-12-25 14:49:15
Microcontrollers
iDraeam94i, 2018-12-25 14:49:15

STM32 how to make a leg an input?

I assembled the circuit on STM32, put 6 legs on the input. Digital.Write set to LOW but still it has 3.3 V, how to make it so that it would be able to read
Code:
int i=0;
void setup()
{
pinMode(PC13, OUTPUT); //LED on pin 13
pinMode(6, INPUT); //6 pin - in input mode. The button is connected to ground.
digitalWrite(6, LOW); //connect pull-up resistor
}
void loop()
{
digitalWrite(PC13, digitalRead(6)); // read the button state and toggle the LED
if(!digitalRead(6) ){
i++;
}
Serial.print(i);
delay(500);
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TyzhSysAdmin, 2018-12-25
@POS_troi

3.3v and will be on this leg in the "input" mode because the pull-up resistor is inside, you can turn it off but you have to install an external resistor and the same situation will come out.
Well, in order to read the state of the leg, it is necessary to catch a low level on it.

C
Cyril, 2018-12-27
@argz

If the foot is on the input, then digitalWrite will not work.
For a pull-up resistor, use
pinMode(6, INPUT_PULLDOWN);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question