Open box

OpenBox is an open source box that contains open source electronics. Oh, and it automatically opens when you knock on it.


  • 1 Arduino Uno board
  • 1 Basic Education shield
  • 1 standard servo
  • 1 piezo
  • 1 1M ohm resistor
  • 3 jumper wires
  • 1 9V battery
  • 1 9V battery holder
  • 1 power connector
  • 1 OpenBox kit
  • masking tape
  • thread
  • 1 breadboard


  1. Connect the shield to the top of your Arduino board.
  2. Connect the 1Mohm resistor to analog pin A0 and to GND through Arduino.
  3. Connect one the legs of the piezo to analogue pin 0, connect the other leg to GND in parallel with the resistor.
  4. Build OpenBox kit but leave the rear cover unassembled.
  5. Turn the servo by hand until the end. Turn it by hand to the position of 90 degrees. Fixing the rod-shaped arm along the servo.
  6. Tie a thread to the servo. Pull it through the hole in the middle plate and tie the other end to the lid.
  7. Connect the servo to D9.
  8. Place your Arduino inside the box. Paste the piezo to the inner wall of the box.
  9. Connect Arduino to the computer and load the example: File -> Examples -> Castilla -> Robots -> OpenBox. Knock on the piezo to make sure the servo moves.
  10. Connect the 9V battery to Arduino before you assemble the rest of the walls.


You cand find the code at: File -> Examples -> Castilla -> Robots -> OpenBox

How it works

When the piezo knock sensor detects a knock, the servo rotates and pulls the string so that the lid is lifted. It waits for a bit and theN rotates back so the lid closes. The program then restarts and you can knock once more.


  1. The lid does not open/close fully? Adjust the values in write() to fix it. But first, adjust the angle of servo arm and the string to make sure it is long or short enough.
  2. The box does nothing when you knock? Check the reference for debugging piezo knock sensor. If it’s still not working, see the reference for debugging standard servo.

Experiment further

  • Make a password knock by setting it to recognize only a certain knock pattern.
  • Modify it so that it requires knocking to both open and close the box rather than automatically closing after it is opened.