Page 1 of 1

is my pyboard broken or am i missing something

Posted: Mon Apr 02, 2018 11:23 am
by rhubarbdog
when i run the following code the light flashes when X5 is connected to 3V3 . the light doesn't flash when disconnected or X5 is connected to GND as expected

Code: Select all

from pyb import Pin, LED, delay

wire=Pin('X5',Pin.IN, Pin.PULL_DOWN)
light=LED(3)

while True:

    if wire.value():
        light.toggle()
    else:
        light.off()

    delay(500)
 
when i change the pin to Y10 the following happens Y10 connected to 3V3 the light is flashing as it is incorrectly when disconnected. it's only when i connect Y10 to GND is it that the light goes out.

it's as though the pull down resistors don't work.

thanks

Re: is my pyboard broken or am i missing something

Posted: Mon Apr 02, 2018 1:14 pm
by Roberthh
The Pyboard has an Pull-up resistor on the PCB, value 4.7 k. That is made to support its use for I2C, which needs a pullup-resistor of that value. The chip internal PULL_DOWN is less strong, so finally the Y10 is pulled up.
So: It's not a bug. it's a feature (honestly).

Re: is my pyboard broken or am i missing something

Posted: Mon Apr 02, 2018 1:28 pm
by rhubarbdog
So should i use external pull down resistors on Y10 and friends. If so can you hint at a typically value

Re: is my pyboard broken or am i missing something

Posted: Mon Apr 02, 2018 3:12 pm
by Roberthh
That would be one option, about 1 k would be required, but not the best. Other options include:
- use a different GPIO port. Only X9, X10, Y9 and Y10 have that pull-up resistor
- change your program logic, in that you connect it to GND instead of 3v3.

Re: is my pyboard broken or am i missing something

Posted: Tue Apr 03, 2018 10:30 am
by chuckbook
If your intention is to use a pin as combined input/output you may have to change your logic. If it is just an output, use it in OUT_OD mode.