We need the following items.
- Arduino IDE
- Node32MCU ESP32 Board
- Download the CP210x Universal Windows Driver.
- Unzip the compressed file.
- Right-click the
silabser.infand select "install".
-
Install Arduino IDE.
-
Open File > Preferences > Settings > Additional boards manager URLs, and then enter the following URL:
Finally, click OK.
-
Open Tools > Board > Boards Manager, and then install
esp32made by Espressif Systems. -
Open Tools > Manage Libraries, and then install the following libraries.
PIDmade by Brett BeauregardArduinoJsonmade by Benoit BlanchonESP32Servo0.13.0made by Kevin Harrington, John K. BennettESP32Encoder0.9.1made by Kevin HarringtonEspSoftwareSerial8.0.1made by Dirk Kaar, Peter LerupAdafruit-PWM-Servo-Driver-Librarymade by Adafruit
We've defined the max. and min. angles for servos at the following code.
const uint8_t servoMinAngles[] = {0, 0, 0, 0, 0};
const uint8_t servoMaxAngles[] = {180, 120, 160, 180, 70};The initial pose is defined via the following code.
void setup() {
// ...
// Create the arm control task
for (uint8_t i = 0; i < NUM_OF_SERVOS; i++) {
currentAngles[i] = (float) servoMinAngles[i];
switch (i) {
case 0:
targetAngles[0] = 90;
break;
case 1:
targetAngles[1] = 0;
break;
case 2:
targetAngles[2] = 160;
break;
case 3:
targetAngles[3] = 50;
break;
case 4:
targetAngles[4] = 10;
break;
default:
break;
}
}
// ...
}