Hi, I am currently trying to make a set of Python codes to upload Arduino codes for me. I am not sure if that is possible, but this is what I currently have:
import serial
import os
ser = serial.Serial('/dev/cu.usbmodem141201', 9600)
string = """#include <Stepper.h>
#define STEPS 200
Stepper stepper(STEPS, 11, 9, 10, 8);
void setup() {
stepper.setSpeed(160);
}
void loop() {
stepper.step(512);
delay(1000);
stepper.step(-512);
delay(1000);
}"""
ser.write(string.encode('utf-8'))
Is this possible? I don't have any errors while processing this code, but Arduino does not receive the code, and my motor never turned. I tried using the Arduino app to upload code, and the Arduino code functions perfectly. I believe this means the problems is at the last line of this code. Can anyone help me? Thanks