Can I use Pins to connect external buttons and LED's?



  • Would it be possible to connect an external button as well as an external LED light to the expansion board? I'm hoping to connect a LoPy4 as well as a few buttons to the expansion board but I'm unsure if this is supported. Are there open pins I can use for general purposes like this?

    Are there any tutorials on working with the pins? It doesn't look like the LoPy documentation has much there unless I'm missing something.



  • @prawnhead thank you! That's exactly what I needed to know :)



  • Hey Cooper, the part in the documentation you need is 6.2.1.4 Pin. This gives you the basics of running an LED from a pin or using a button as an input.

    If you connect a button between a pin and ground (0V) then you need to configure the pin with a pull-up resistor. Vice-versa works too: a button between the pin and 3.3V with a PULL_DOWN on the pin.

    p_in = Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP)
    

    When you connect an LED to a pin you need a resistor in series with the LED. 220ohms should work.

    When you look at the LoPy Pinout Diagram all those pins marked as GPIOxx can be a button input or LED output. So you can use lots!

    • Chris.

 

Pycom on Twitter