Group 1: Magic box
Description of project:
We have designed a prop which will have a similar function as a safe used to store another prop. This box could be used in adventure type plays, where the user would have to figure out a combination of the box to ‘steal’ the treasure. At the end once this treasure is ‘stolen’ this would trigger an alarm, possibly setting off a ‘trap’ in the play.
Its main functions include:
- Guessing the pattern input of the buttons. This will determine what sound and light the box will display depending if the answer of the input is correct or not.
- Use of the LDR to detect changes of light in the environment.
- The turning of the gears and spinning of the servo. This will only be stimulated once the correct set of buttons is pressed.
- Automatic opening of the box once the right combination is chosen
- The stimulation of the alarm once the item within the box is removed.
Meetings:
10th November 2020
In this meeting we developed a mind map of all the possible ideas for the theatrical prop project. These consisted of a wand that responds to movement, a cigar that is lighted with the touch of another component, and an interactive safe box used to store a hidden ‘treasure’.
The outcome of this meeting was the decision of our project direction. We decided upon making a box that will accommodate the need for a safe that is commonly used in adventure type plays. The aim was to make this prop stand out from the previous ones that have already been used in the industry, and to incorporate new features like LDR’s and ways of opening the box, like using a servo to do this instead of a motor.
16th November 2020
Here we decided on the functionality that will be integrated into the box. We did this by using a commonly used Lo-Fi prototype: storyboarding. It portrays the way each mechanism will function after a certain user action is taken and these user actions are categorised in simple steps as seen in the storyboard.
In this meeting we discussed some of the preconceived design concepts which we can incorporate, that would help the user know how to use the theatrical prop such as:
- Colouring of the lights and using the connotations of specific colours to give visual feedback to the user. So when the input combination is wrong, the box turns red and when it is green it automatically let’s the user and the audience know that their guess was correct.
- Auditory feedback also demonstrates this same concept. We decided to use an alarm sound when something is stolen from the box and two different sounds for the incorrect and correct guesses.
After identifying the key functions and attributes of our box, we split the code into components, between ourselves, that will each need to be individually tested.
Group responsibilities:
- Julia worked on the motor to spin the gears, servo, changing LED light colours, and the 5 touch sensors at the front of the box that will open the door if the combination is correct.
- Gabriele worked on LDR, sound feedback, the inside button to trigger the alarm, and the flashing light code.
This splitting of the components let us decide upon the timings needed to complete the code for each one. A chart of timings and a plan was developed after this meeting.
23rd November 2020
The code of each individual component was made and put together, and the first attempt of the final circuit was assembled. Any shortcomings were discussed and evaluated, which led to the development of the final circuit.
To begin with the code was split into parts which include making the led blink, figuring out how to make a siren sound with the piezo and using the button to trigger these events.
Initially when we set up and tested the piezo element, it would make a high-pitched noise whenever the loop for the melody is stopped. This problem was solved by changing the set-up of the piezo and button on the breadboard and making sure the piezo pin was changed from pin 11 to pin 8. This was because the tone() function interfered with the output on pin 11.
The picture above is the modified version of the circuit which no longer produced the high-pitched noise when the button wasn’t pressed.
The rest of the components where connected with the aid of the lab sheets
Once the LED steps arrived we connected them to a 5 volt battery and found out they were broken, so we changed our circuit layout and added a shift register with 4 green and 4 red leds. This was done so that there is a clear indication when the result is right and when it is wrong.
Then the piezo, touch sensors and button were added to the circuit and the entire circuit was put together.
The final circuit
3rd of December 2020- maker manual of the functioning prototype
Documentation and prototype were completed. The prototype was made from materials that included: cardboard, tape and wire. The circuit was then implemented within the box and attached to their corresponding areas of use.
Project task list
Table of components:
Component | Description | Who is responsible |
Piezo | To give back feedback if input was correct or not | Gabriele |
Plays a siren sound when item is removed from box | Gabriele | |
LDR | Turns lights on and off depending on the lighting of surroundings | Gabriele |
Button | Triggers lights and sound once weight is lifted and is unpressed | Gabriele |
LEDs | Starts flashing when alarm goes off | Gabriele |
Turns on green LEDs when correct input is selected and red LEDs when incorrect | Julia | |
Servo | Turns on when input is guessed. This will lift the lid of the box to open it. | Julia |
Touch sensors | 3 correct sensors will need to be pressed to open the box and to set off other components. | Julia |
Motor | Used as decoration to spin the gears when the box is opening. | Julia |
Putting all the components together | Assembling of the final circuit and code | Julia |
Timing plan:
Makers manual
Final product:
The final product is a magic box used to store another prop. It can be used in adventure type plays, where the user would have to figure out a combination of the box to ‘steal’ the treasure. This combination provides auditory and visual feedback to notify the audience of the outcome.
At the end once this treasure is ‘stolen’ this would trigger an alarm, possibly setting off a ‘trap’ in the play.
This will accommodate the need for a safe that is commonly used in adventure type plays.
The aim is to make this prop stand out from the previous ones that have already been used in the industry, and to incorporate new features like LDR’s and ways of opening the box, like using a servo to do this instead of a motor.
List of final components and materials to make final product:
- Piezo element
- LEDs – 4 green and 4 red
- 4 Touch sensors
- Servo
- Motor
- Jump wires
- LDR
- Transistor
- Button
- Capacitor
- Cardboard – required scissors to cut out and hot glue to put it together
- Wire
- Tape
- Shift register
Final Breadboard Layout:
Prototype build:
The cardboard skeleton of the box was initially set up and taped together, followed by the attachment of the top lid using tape and wire. This wire was attached to the servo, which lifted the lid of the box once the input combination was guessed correctly.
We then created holes for the LDR and gears. One of these gears was connected to the motor, located inside the box, which spun the remaining gears on the outside. This technique was used to create the effect of the box unlocking, adding an extra point of interest and interactivity with the audience. However, this had to be taken out at the end due to there not being enough space to connect the motor on the board.
The 4 touch sensors were then attached to the 4 rectangular holes at the front and the final circuit was inserted within the box. A weight was put onto the inside button to represent the treasure that would be placed in the box, when it is used in theatre. The result of removing this weight would cause the alarm and siren to go off.
Lastly, the LEDs were attached around the touch sensor holes. These were used to give the user feedback depending on the button input at the front of the box. For example: they would turn green if correct input is selected and red if incorrectly guessed.
Final compiled code:
int b2 = 5; //first touch sensor to pin 5
int b3 = 6; //second touch sensor to pin 6
int b4 = 7; //third touch sensor to pin 7
int b5 = 8; //fourth touch sensor to pin 8
int arrayOg[] = {3, 1, 2}; //array of the correct choice sequence
int array[] = {0, 0, 0}; //initializing the array to be chosen
int arrayPos = 0; //initialising the position of the the array
int piezo = 9; //initialising the piezo to pin 9
const int buttonPin = 11; //initializing the button to pin 11
int i = 0;
int buttonState = 0; //state of button
const int ldrPin = A0; //initialising the ldr to the analogue pin 0
byte leds = 0; //setting the leds to off
int latchPin = 4; //initialising the latch of the shift register
int clockPin = 3; //initialising the clock of the shift register
int dataPin = 2; //initialising the data of the shift register
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; //position of servo
void setup() {
pinMode(b2, INPUT);
pinMode(b3, INPUT);
pinMode(b4, INPUT);
pinMode(b5, INPUT);
pinMode(piezo, OUTPUT);
myservo.attach(10);
myservo.write(pos);
pinMode(buttonPin, INPUT);
pinMode(ldrPin, INPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
}
void loop()
{
idrStart(); //calling the starting function
}
void idrStart() {
int ldrRead = analogRead(ldrPin);
if (ldrRead <= 500) { //if idr is less than 500 the leds turn on
updateShiftRegister(255); //function that turns leds on
delay(500);
for (int i = 0; i < 8; i++) { //loop to go through each led and turn it oon
bitSet(leds, i);
updateShiftRegister(255);
choiceArray(); //calls function for touch sensors
}
}
else {
for (int i = 0; i < 8; i++) {
bitSet(leds, i);
updateShiftRegister(0); //if ldr is not less than 500 then the leds turn off
}
}
}
//function that controls leds using shift register
void updateShiftRegister(int ledVal) {
digitalWrite(latchPin, LOW); //closes latch
shiftOut(dataPin, clockPin, LSBFIRST, ledVal); //changes led value
digitalWrite(latchPin, HIGH); //opens latch to apply new led value
}
//function to make the servo turn
void servo() {
for (pos = 0; pos <= 90; pos += 1) { // goes from 0 degrees to 90 degrees
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}
//function for the button in the end
void alarmButton() {
// read the state of the pushbutton
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
while (buttonState == HIGH) { //remains in this loop until buttonState is low
buttonState = digitalRead(buttonPin);
};
if (buttonState == LOW) {
//for leds to blink
for (int i = 0; i < 8; i++) {
bitSet(leds, i);
updateShiftRegister(0);
}
for (int i = 0; i < 8; i++) {
bitSet(leds, i);
updateShiftRegister(255);
}
for (i = 700; i < 1000; i++) { //play sound for the alarm
tone(piezo, i);
delay(15);
}
for (i = 1000; i > 700; i–) {
tone(piezo, i);
delay(15);
}
}
}
//function for which touch sensor is chosen
int testButton() {
if (digitalRead(b2) != LOW) {
delay(1000);
return 1;
}
if (digitalRead(b3) != LOW) {
delay(1000);
return 2;
}
if (digitalRead(b4) != LOW) {
delay(1000);
return 3;
}
if (digitalRead(b5) != LOW) {
delay(1000);
return 4;
}
}
//function for puting the chosen values in an array and comparing it to the original array
void choiceArray() {
if (digitalRead(b2) != LOW || digitalRead(b3) != LOW || digitalRead(b4) != LOW || digitalRead(b5) != LOW) {
array[arrayPos] = testButton(); //calls function and stored its return in the array
arrayPos++; //increments array position by 1
delay(500);
}
if (arrayPos == 3) { //if all positions have been filled
if ((array[0] == arrayOg[0]) && (array[1] == arrayOg[1]) && (array[2] == arrayOg[2])) { //comparison of arrays, if arrays are the same
for (int i = 0; i < 8; i++) {
bitSet(leds, i);
updateShiftRegister(240);//turns green leds on
tone(piezo, 1915 ); //buzzer
delay(200);
tone(piezo, 1275);
delay(200);
noTone(piezo);
servo(); //calls servo function
alarmButton(); //calls final button function
exit(1);
}
}
else { //if arrays dont match
for (int i = 0; i < 8; i++) {
bitSet(leds, i);
updateShiftRegister(15); //turns on red leds
}
tone(piezo, 1275 ); //buzzer
delay(200);
tone(piezo, 1915);
delay(200);
noTone(piezo);
array[0] = 0; //returns array to its original state so they can guess again
array[1] = 0;
array[2] = 0;
arrayPos = 0;
delay(1000);
return;
}
}
}
Testing conducted:
Each component added to the board was first tested on its own using basic code just to see if the components were set up correctly on the board. Additionally every function created was also tested in a separate sketch before being added to the main code in order to test if the function was performing the tasks we wanted it to. The serial monitor also played a big part in our testing process, especially to test out the choiceArray function which was used for the selection of the touch sensors. It was set to output which touch sensor was being touched as well as a yes or no response to show if the result was right or wrong. This helped us find and solve any bugs related to the touch sensors to make sure they worked properly. Lastly the led strips were tested using a 5 volt battery pack separate from the board and that is when we found out that they had arrived broken and could not be used.
Shortcomings:
One problem we encountered was that the LED strips were not working. We decided to use clear, separate LEDs instead and change the code so these can be changed to the desired colour. However, due to there being too many components connected to the pins, we have run out of space on the board to connect them. Therefore we used 4 green and 4 red LEDs which would be activated depending on the outcome.
Additionally, the motor had to be removed due to this same problem. Out of all components we decided to take out this one as it was used more for decoration purposes rather than for a functional aspect of the box. However, we still decided to keep the code for it in the final program, so that if there were more space on the board we would be able to use it in the final product.