Arduino Box

by Gugalu in Workshop > 3D Printing

11951 Views, 80 Favorites, 0 Comments

Arduino Box

13181146_10207924804572049_86714105_n.jpg

Objective:

The objective of this project was to make a case for an Arduino (MEGA).

This box need to open and close with a button and the other objective of this project was my developing 3D design.

Design

arduino box.PNG

For the design of this arduino box I used the trinkerCAD

The Box

13231017_10207924725450071_1327034249_n.jpg

Problems

13180908_10207924724890057_1859319068_n.jpg

I went through many problems since making the hinge to where and how to place the button.

Attempts Servos Arm

13115872_10207924725370069_1456695958_n.jpg

Servo´s Arm

13235735_10207924725050061_1928736365_n.jpg

Programming

13180871_10207924663248516_1204622730_n.jpg

//Button Toggle Servo

#include

Servo servo; // create servo object to control a servo

// twelve servo objects can be created on most boards

const int buttonPin = 2;

boolean lastState = LOW;//storage for last button state

boolean pos = true;

void setup()

{

servo.attach(9); // attaches the servo on pin 9 to the servo object

pinMode(buttonPin, INPUT_PULLUP);//this time we will set the pin as INPUT

Serial.begin(9600);//initialize Serial connection

}

void loop()

{

boolean currentState = digitalRead(buttonPin);

if (currentState == LOW && lastState == HIGH)

{

Serial.println(pos ? "up" : "down");

servo.write(pos ? 90 : 0);

delay(150);

pos = !pos;

}

lastState = currentState;

13187735_10207925166901107_1960158656_n.jpg