Testing the servo motor

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
Only three connections are needed to connect the servo: VCC, ground, and pin 9(this image was created ...

Get Hands-On Internet of Things with MQTT now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.