We need the following items.
- Arduino IDE
- Node32MCU ESP32 Board
- Download the CP210x Universal Windows Driver.
- Unzip the compressed file.
- Right-click the
silabser.inf
and 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
esp32
made by Espressif Systems. -
Open Tools > Manage Libraries, and then install the following libraries.
PID
made by Brett BeauregardArduinoJson
made by Benoit BlanchonESP32Servo
0.13.0
made by Kevin Harrington, John K. BennettESP32Encoder
0.9.1
made by Kevin HarringtonEspSoftwareSerial
8.0.1
made by Dirk Kaar, Peter LerupAdafruit-PWM-Servo-Driver-Library
made 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;
}
}
// ...
}