Arduino UselessLegoBox

Introduction: Arduino UselessLegoBox

Instruction how to create a uselessbox from lego with an Arduino

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: What Do You Need

To create a uselessbox from lego I used the following parts

  • Arduino One
  • 2x Servo motors (SG90)
  • Collision switch
  • Breadboard
  • Led
  • Resistor
  • Jumper cables

Step 2: Create the Useless Box

It pretty hard to get the lego so that it works, and connect the servo's to the lego. I used some screws to screw a cog-wheel to the servo.

I used one servo to open the door of the box and the other for moving the switch back (turn it off again). When you are done with the mechanical part you can close it all up.

Step 3: Connecting It All Together

Connect the 5v from the Arduino to the + of the breadboard and the GND to the - of the breadboard. Next connect the + and - of the breadboard to the + and - of the servo's and connect the signal wires to the A0 and A2 of the Arduino (I connect everything to the breadboard first)

Connect the collision sensor GND and VCC to the - and + of the breadboard and connect the out/signal to the digital 4 pin of the Ardiono.

Place the Led on the breadboard, connect the + (long leg) to the digital pin 6 of the Ardiono. Connect the - (short leg) to the resistor and the other end of the resistor to the - of the breadboard.

Step 4: The Code

The code is pretty strait forward

Setup some values, lower and upper bound of the servo motors, pins of the led and sensor.


Servo servo1;
Servo servo2;

#define UP 10
#define DOWN 60

#define DOOR_UP 60
#define DOOR_DOWN 10

#define BUTTON 4
#define LED 6

Initialise the motors and set them to the closed position
void setup() {

pinMode(LED, OUTPUT);


Check each loop if the button is pressed to trigger the motors with a random delay

void loop() {

int val = digitalRead(BUTTON);
if (val == LOW) {

digitalWrite (LED, HIGH);
int rnd = random(1000, 4000);

} else {

digitalWrite (LED, LOW);



Helper function to move the handle and the door

void moveDown(){

Serial.println("Move down"); servo1.write(DOWN);


void moveDoorDown() {



void moveDoor() {

Serial.println("move door");


void moveHandle() {

Serial.println("move up");



Step 5: Finished

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Finish It Already Speed Challenge

      Finish It Already Speed Challenge