Final Project

Plan for Final Project

When I started planning for a final project, I was thinking about making a puzzle box. One that opens after a combination of button presses. While I am still interested in this project, my goals have changed. Instead of this box being used as a curiosity, I want to use this box as a educational tool to stimulate interest in simple programming. Specifically, I want this box to have various buttons and LEDs and have access to reprogram it. In this way the box will be modable and hackable. It will have basic functionality, but students will be encouraged to reprogram it to change the way it opens.

Online, there are designs for various GPS puzzle boxes and machines that turn themselves off that are similar in basic design, but none that I can find that are similar in design to this type of box. I will use one of the fab lab Arduino clones for the box, probably the Barduino as I have had some success making it in the past.

Materials needed - Will be updated with details as I progress through the specifics.

I need to make the Arduino clone board, the LED board, the servo assembly and the box to contain it. The boards will be designed in Eagle and milled and stuffed in the lab. I will attempt to program it in well-documented code using the Arduino programming panel. The case will be designed on the computer and cut using the laser cutter. If I can easily attach the servo assembly to the case I will, if not I will create a bracket using the 3D Printer.

If I am quickly successful, I can expand on the project by adding another sensor board or a LED array. Otherwise those will be left as excersises for my students. The plans will be left online free for others to use.

I have designed the boards and have them mostly ready to go. I created a button board to test some ideas, and should be ready this week to get an unboxed prototype working. Them I will design the box and get the servo assembly working. Finally I need to assemble the box.

I put together the LED board and wired it to the Barduino, but it did not work. Instead of blinking all 4 lights in succession, the first 2 stayed on and the second two stayed off. Hmm.

After much work, I found a bad trace connecting one of the pins - it looked fine, but the meter said otherwise. Fixing that by resoldering it and removing a small solder bridge, I managed to get the LED board to work.

Next I started designing the box. I created it in 2 parts and first used cardboard.

Once I had it where I wanted, I made it out of .25' plywood.


My Barduino was very erratic. It sometimes programmed fine, other times it gave error messages. Even when it worked, there were strange error conditions. After much work trying to figure out where my Barduino had a problem, I made a different Arduino clone. This time I used Anna's version of the hello.arduino. It gave me no problems and programmed right away. I also was using the ATMega 328P this time and that may have also made a difference.

I decided to wire the box so that each of the 4 buttons lights one of the 4 LEDs. Once that was done, 3 of them worked, but one of the LEDs refused to light. I could get the LED to light if I put current directly on the leads, but I could not get it to work normally. Undaunted, I still attempted to program the box. Opening the box is a 3 step process -- After each correct "number", the LEDs all light and stay lit for a few seconds. After the last correct step, the LEDs light and the servo should move.

This was remarkable easy, and after a few hours of coding, I managed to get the program where I wanted it. I bypassed the control wire leading to the LED and it now worked as well. I suspect a connection problem in the connector on the board.

The box now works, but there are a few items left to do. I need to actually make the hook that the servo connects to to lock the box. I would like to make a battery source so that the box can be transported. I would also like to place a smaller box on the interior to hide the wiring. Finally, I need to permanently attach the bottom of the box.

/*
  Puzzle Box code
  C Wiemer 2013
  Feel free to use and modify as you wish.
 
 */
#include 
Servo myservo;
int counter = 0; //counts successful numbers found
const int firstLight = 7;
const int secondLight = 6;
const int thirdLight = 8;
const int fourthLight = 5;
const int rightButton = 3;
const int backButton = 4;
const int frontButton = 9;
const int leftButton = 10;

// the setup routine runs once when you press reset:
void setup() {
  pinMode(rightButton, INPUT);
  pinMode(backButton, INPUT);
  pinMode(firstLight, OUTPUT);  
  pinMode(secondLight, OUTPUT); 
  pinMode(thirdLight, OUTPUT); 
  pinMode(fourthLight, OUTPUT);      
  pinMode(frontButton, INPUT);
  pinMode(leftButton, INPUT);
  pinMode(A0, OUTPUT);
   
// enable built in pullup resistors
  digitalWrite(rightButton, HIGH);
  digitalWrite(leftButton, HIGH);
  digitalWrite(backButton, HIGH);
  digitalWrite(frontButton, HIGH);

myservo.attach(A0);
myservo.write(0); 
}

// the loop routine runs over and over again forever:
void loop() {

   if (digitalRead(rightButton) == LOW) {    
    // turn LED on:   
    digitalWrite(secondLight, HIGH); 
  }
else
    // turn LED off:
    {
    digitalWrite(secondLight, LOW);}
 
    if (digitalRead(leftButton) == LOW) {    
    // turn LED on:   
   digitalWrite(firstLight, HIGH); 
  }
  else {
    // turn LED off:
    digitalWrite(firstLight, LOW);
  }
     if (digitalRead(frontButton) == LOW) {    
    // turn LED on:   
    digitalWrite(thirdLight, HIGH); 
  }
  else {
    // turn LED off:
    digitalWrite(thirdLight, LOW); 
  }
     if (digitalRead(backButton) == LOW) {    
    // turn LED on:   
   digitalWrite(fourthLight, HIGH); 
  }
else {
    // turn LED off:
    digitalWrite(fourthLight, LOW);   
  }
 
  if (digitalRead(rightButton) == LOW && digitalRead(leftButton) == LOW && digitalRead(frontButton) == HIGH && digitalRead(backButton) == HIGH  && counter == 0)
 {
  digitalWrite(firstLight, HIGH);
  digitalWrite(secondLight, HIGH);
  digitalWrite(thirdLight, HIGH);
  digitalWrite(fourthLight, HIGH);
  delay(2000);
  counter += 1;
 }
   if (digitalRead(rightButton) == HIGH && digitalRead(leftButton) == LOW && digitalRead(frontButton) == HIGH && digitalRead(backButton) == HIGH && counter == 1)
 {
  digitalWrite(firstLight, HIGH);
  digitalWrite(secondLight, HIGH);
  digitalWrite(thirdLight, HIGH);
  digitalWrite(fourthLight, HIGH);
  delay(2000);
  counter +=1;
 }
  if (digitalRead(rightButton) == LOW && digitalRead(leftButton) == LOW && digitalRead(frontButton) == LOW && digitalRead(backButton) == HIGH && counter == 2)
 {
  digitalWrite(firstLight, HIGH);
  digitalWrite(secondLight, HIGH);
  digitalWrite(thirdLight, HIGH);
  digitalWrite(fourthLight, HIGH);
  delay(3000);
 
  myservo.write(90);  //open box code here
  delay(6000);
  counter = 0;
 }
}
back to index