Quantcast
Viewing all articles
Browse latest Browse all 1288

Python • Raspberry Pico Websocket

Hello

I'm working on a personal project for sending some websocket message from pico w with micropython.
I use this library aiohttp and I'm trying to send some messsage when a button is pressed

Code:

async def main():    session = aiohttp.ClientSession()    async with session.ws_connect('URL') as ws:        await button(ws)        async for msg in ws:            await button(ws)                async def button(ws):    while True:        player = 'test'                if button1.is_pressed:            print('button is pressed')            player = 'buzzer1'    await ws.send_str(player)                
When I pressed the button message is not sent

Can you help me please ?

Statistics: Posted by wanexa — Tue Jun 25, 2024 3:57 pm



Viewing all articles
Browse latest Browse all 1288

Trending Articles