Now that your network connection is working, as is the sending and receiving of MQTT messages, we need to do yet another mini-sketch to test whether the servo motor is working. Afterward, we will put the pieces of the puzzle together and create the code for our smart pet food dispenser.
To connect the servo motor, you need to connect the three cables of the servo to the Arduino. To connect the servo motor cable (with female pins) to the female Arduino pin headers on top, you can use the male-male jumper wire cables.
Connect the cables as follows:
- Black (or brown): GND
- Red: VCC
- Orange (or yellow/green/white): Pin 9