Where are some examples?



  • I just received a couple of WiPy 2.0 boards. Do you have a working example program I can download and run? I'm a newby to micropython and need a simple example, like pushing a button on one board and having an LED light up on the other board, sending data via WiFi. I looked under "tutorials and examples" but didn't see any examples there.





  • Thanks, LoneTech. I'm really looking for a WiFi example, something that would show network setup and transfer of data from one board to another.



  • Here's a sample I've tried on my LoPy on the expansion board:

    from machine import Pin
    
    led = Pin("G16",  mode=Pin.OUT)
    #button = Pin("G17",  mode=Pin.IN,  pull=Pin.PULL_UP)
    button = Pin("G17",  mode=3)
    
    while True:
        led(button())
    

    Note that the mode=3 is a workaround for a bug that should be fixed in tomorrow's firmware update; the commented out version is how it should've been. This script runs a loop that simply sets the LED state from the button state. I hope to update it to use an IRQ later.

    I've also run basic network communication, but not yet directly between the LoPys (just basic testing, like using socket.getaddrinfo to confirm internet connection). When WLAN is set up, the socket module basically behaves like in normal Python.


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.