Whelp I bought and ESC, motor and Adruino for testing. Been working on the code. It doesn't work yet because I'm still trying to figure out how to get four digital input pins to make an output do four different speeds.
#include <Servo.h>
#define ButtonPin 0
#define ButtonPin 1
#define ButtonPin 2
#define ButtonPin 3
#define MotorPin 11
Servo ESC;
int IN1 = 0;
int IN2 = 1;
int IN3 = 2;
int IN4 = 3;
void setup() {
pinMode(IN1, INPUT);
pinMode(IN2, INPUT);
pinMode(IN3, INPUT);
pinMode(IN4, INPUT);
pinMode(IN1, INPUT_PULLUP);
pinMode(IN2, INPUT_PULLUP);
pinMode(IN3, INPUT_PULLUP);
pinMode(IN4, INPUT_PULLUP);
ESC.attach(11,1000,2000); // (pin, min pulse width, max pulse width in microseconds)
}
void loop() {
if (digitalRead(0) == LOW) {
IN1 = map(11, 0, 1023, 0, 180); // scale it to use it with the servo library (value between 0 and 180)
ESC.write(11); // Send the signal to the ESC
}
if (digitalRead(1) == LOW) {
IN2 = map(11, 0, 1023, 0, 180); // scale it to use it with the servo library (value between 0 and 180)
ESC.write(11); // Send the signal to the ESC
}
if (digitalRead(2) == LOW) {
IN3 = map(11, 0, 1023, 0, 180); // scale it to use it with the servo library (value between 0 and 180)
ESC.write(11); // Send the signal to the ESC
}
if (digitalRead(3) == LOW) {
IN4 = map(11, 0, 1023, 0, 180); // scale it to use it with the servo library (value between 0 and 180)
ESC.write(11); // Send the signal to the ESC
}
else {
have speed be 0
ESC.write(11);
}
}