Chocolate Box – Arduino

The less complicated part of the whole project is the one that brings the WOW factor!

We are all so used to the wonders of the Internet, interconnected devices, screens, and even voice-activated assistants like Alexa that as soon as things move, we all stare in awe.

To achieve such an effect, with the box that self-opens and closes, only three pieces of hardware are strictly required: a microcontroller, and two servos.

Hardware List

  • Arduino MKR1000.
  • 2# Servo.
  • Wires.
  • Breadboard.
  • Micro-USB Cable.

I went for an MKR1000 because it has integrated WiFi capabilities, and it was sitting in a drawer in my studio. Any WiFi-powered Arduino would actually do the job.

The servos are super basic too. I used two SG90 I had spare, but anything similar would do.

Wires and breadboard made the circuit easy to build and easy to tear down without any soldering or permanent connection.

The whole circuit is powered via a Micro-USB cable connected to a phone charger. This gives a handy 5V power supply for the servos without a dedicated power circuit.



The sketch for the MKR1000 is available on GitHub, with all the other resources.

The code initializes the Wi-Fi connection and subscribes a topic on the MQTT Broker. It then moves the servos according to the message it receives.

Important to notice, in the code, how the two servos are mounted facing each other, so they move in opposite angles. Not a big deal, but it might look cryptic in the code.

In the next posts, I’ll show how the cardboard box is built and how to make the Alexa interface to sound nice when it receives the command. Stay tuned!

Previous posts: Intro, Overview, Infrastructure/Logic.





Leave a Reply

Your email address will not be published. Required fields are marked *