I am trying to control a BLDC motor (with esc) with my arduino. The arduino is reciving commands from a serial connection with a raspberry pi running a python program that repeatedly sends numbers to control the motor.
I intend to control the speed of the motors via the raspberry pi over a serial connection. So far i have never been able to spin the motor while sending data.
include <Servo.h>
Servo ESC; // create servo object to control the ESC
int incomingByte = 0;
void setup() {
Serial.begin(9600);
ESC.attach(3,1000,2000); // (pin, min pulse width, max pulse width in microseconds)
}
void loop() {
ESC.write(Serial.parseInt());
//incomingByte = Serial.parseInt();
}
import tkinter as tk
import serial
tracked_var = 0
def outputValue():
print(tracked_var)
ser.write(value.encode())
window.after(50, outputValue)
def update_tracked_variable(value):
global tracked_var
tracked_var = value
def background(color):
window.configure(bg=color)
scale = tk.Scale(window, from_=0, to=20, command=update_tracked_variable)
scale.pack()
ser = serial.Serial('/dev/ttyUSB0', 9600)
window = tk.Tk()
window.title("Drone Control")
background("black")
outputValue()
window.mainloop()
When I send the values to the arduino I get no movement from the motor. This code was slightly changed from a simple potentiometer servo controller.