Hello, I just can not find a solution to the simple task of activating a pin on arduino through a function call in python. The problem is that there is a delay of half a second due to (as I understand it) the expectations of the readiness of the microcontroller. Is it possible to avoid delays?
Python
import serial, time ON = ":00000008f8" ser = serial.Serial('COM3', 57600) time.sleep(0.28) // если убираю здесь, то пин не активируется #ser.flush() ser.write(ON) time.sleep(1) ser.close() Arduino:
const int pin = 2; void pulseLed() { digitalWrite(pin, HIGH); // sets the pin on delay(200); // pauses for 50 microseconds digitalWrite(pin, LOW); // sets the pin off delay(200); // pauses for 50 microseconds } void setup() { pinMode(pin, OUTPUT); // set pin to input // initialize serial: Serial.begin(57600); } void loop() { // serial read section while (Serial.available()) // this will be skipped if no data present, leading to { if (Serial.available() >0) { pulseLed(); } } }