Используя частицу с питоном

Я работаю над проектом в частице с использованием кнопки Интернет, а также над программой на Python. Как бы я скомбинировал свой код частиц, чтобы код Python затем выполнял код частиц, как лучше всего их объединить?

#include <Arduino.h>

#include <InternetButton.h>

InternetButton button = InternetButton();

bool rainbow_mode = false;
int buzzer = D0;

void setup() {
    button.begin();
    pinMode(buzzer, OUTPUT);

}

void loop() {


if (button.allButtonsOff()) {
    button.rainbow(5);
}

if (button.buttonOn(1)) {
    button.allLedsOff();
    tone(buzzer, 2000, 500);
    delay(1000);

}

}

С моим кодом в Python:

def on_message(ws, message):
global KETTLEIP
global LIGHTIP
global MACADDRESS
print (message)
#tweet(message)
if (message == "kettle"):
    if kettle_ip.exists():
        file = open("ketIP", "r")
        data = file.read()
        ket.setOn(data)
elif ("lights" in message and "on" in message):
        light.setAll(LIGHTIP)
elif ("lights" in message and "off" in message):
    light.setOff(LIGHTIP)

def on_error(ws, error):
print (error)


def on_close(ws):
print ("### closed ###")

def on_open(ws):
print ('Opening Websocket connection to the server ... ')


if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("ws://",
                           on_open=on_open,
                           on_message=on_message,
                           on_error=on_error,
                           on_close=on_close,

                                )
ws.on_open = on_open
ws.run_forever()

Что я хочу сделать, так это свет, затем запустить код на частице тоже

0 ответов

Другие вопросы по тегам