Horror Tunnel
Our project is about a horror tunnel in which the "user" walks in, and can experience different effects; like lights or servos, and spiders that scares the users that cross it. In this case, we can see how it works, by moving the hand across the mini tunnel that we made in a smaller prototype.
Supplies
The tools we needed were:
- Arduino one board
- Protoboard
- 4 red LEDs
- pins male to male jumper wire
- USB A to USB B for Arduino
- 3 white LEDs for the photosensors
- 5+ resistance of 240
- one servo
- 3 photosensors
- pressure sensors
- 5 wood sticks of 10x1x1cm
- 1 wood platform of 35.5x15x0.3cm
- 2 wood sticks of 35.5x1x1cm
- 3 wood sticks of 14.5x1x1cm
- black fabric
We design and create the code to run all the actions we are looking for in our horror tunnel with the following code
+ we add flow chart that we made
/*This is the program of the tunnel of the horrors, designed in the 3th course of Industrial Design Engineering
as a part of Usos académicos en terminología específica en inglés I
Program modified by: Isabel Ruiz and Jan Esteba
Tutored by: Jonathan Chacón
October 2022
ELISAVA
*/
//This is where the servo is declared in the library
#include <Servo.h>
//This first part is where the LDR variables are defined
const int ldrPin1 = A1; // we define were the LDR1 is connected in the Arduino Board
const int ldrPin2 = A2; // we define were the LDR2 is connected in the Arduino Board
const int ldrPin3 = A3; // we define were the LDR3 is connected in the Arduino Board
//This second part is where the pressure variables are defined
int AnalogPin = 0; // This is the pressure sensor in the analog pin 0
int LEDpin = 6; // This is where the LEDs of the fade are connected, in pin 6
Servo servo; //We use the librrary servo to have and output in PIN 9
int reading; //We declare the reading as an integer variable
int fadeValue = 0; // the fadevalue starts at 0
unsigned long lastT;
bool anada = false; // We declare as the anada of the loop is false for the non-blocking code
bool timerOn = false; // We do the same as before, to set the timer as false for the non-blocking code
//In the void setup, we declare the variables for both sensors
void setup() {
Serial.begin(9600); //We set a quote to see the status in the serial monitor
pinMode(LEDpin, OUTPUT); //We will define the LEDpin as an output
servo.attach(9); //The servo is attached in the pin 9
servo.write(0); //The servo starts at this value
lastT = millis();
}
unsigned long servoDelayTime = 500; //The servo delay time starts at 500ms
unsigned long servoPastTime = millis(); // We declare as the servo == the millis each reading
int selectCounter = 4; // The selectcountes starts at 4
bool servomove = false; //The servomove intially equals to false.
bool bucle = true;
void loop() {
//In this part we will define the Part of the LDR SENSOR LOOP
int ldrStatus1 = analogRead(ldrPin1); //In here we define the status of the LDR1 equals from an analog read of the LDR pin connection
int ldrStatus2 = analogRead(ldrPin2); //In here we define the status of the LDR1 equals from an analog read of the LDR pin connection
int ldrStatus3 = analogRead(ldrPin3); //In here we define the status of the LDR1 equals from an analog read of the LDR pin connection
int LEDStatus = analogRead(LEDpin); //In here we define the status of the LED's equal from an analog read of the LED pin connection
//This is where the LDR non-blocking code part is defined, following a non-blocking structure.
int servoStatus = analogRead(servo.attach(9)); //The servostatus equals to the reading in the servo.attach in the pin 9 of the arduino.
if (ldrStatus1 <= 400 || ldrStatus2 <= 400 || ldrStatus3 <= 400) { //When the reading of the ldr is higher than 400 will execute the next part, if not will do the other part
if (timerOn == false) {
lastT = millis();
timerOn = true;
anada = true;
}
if (millis() - lastT < 10000) { // If the "millis() - lastT < 10000" executes this part
if (anada == true) { //If anada equals to true, executes this part
analogWrite(LEDpin, fadeValue);
fadeValue += 2; //Makes the fadevalue add up 2 to the count before
if (fadeValue >= 255) { //And not until the fadevalue is up to 255 the fade won't stop
anada = false;
}
} else {
analogWrite(LEDpin, fadeValue); //in this part executes the opposite code in order to make the fade go to 0
fadeValue -= 2;
if (fadeValue < 0) {
anada = true;
}
}
} else {
timerOn = false;
}
} else {
analogWrite(LEDpin, 0); //When the timerOn is on dalse, the LEDPin gos to 0 making the LED turn off immidiatly
}
//This is where the LDR non-blocking code part is defined, following the same structure as before.
if ((analogRead(A0) <= 20) && (servomove == false)) { //If the analogread is less than 20 and the servomove is false then the counter goes to 0, the servo doesn't move
servo.write(0);
} else {
if (bucle) {
bucle = false;
servomove = true;
servoPastTime = millis();
selectCounter = 0;
}
/*If the analogread is less than 20 and the servomove is on true, the servo starts moving in the 3 different cases, 0,1,2, makign the servo
move first from 0 to 180, then to 90 and later back to 0*/
if ((analogRead(A0) <= 20) && (servomove == true)) {
switch (selectCounter) {
case 0:
// servo turns from 0 to 180, waits one second (milis)
servo.write(180);
if ((millis() - servoPastTime) >= servoDelayTime) {
selectCounter = 1;
servoPastTime = millis();
}
break;
case 1:
servo.write(90);
if ((millis() - servoPastTime) >= servoDelayTime) {
selectCounter = 2;
servoPastTime = millis();
}
break; // servo turns from 90 to 0, waits one second (milis)
case 2:
servo.write(0);
if ((millis() - servoPastTime) >= servoDelayTime) {
selectCounter = 0;
servoPastTime = millis();
servomove = false;
bucle = true;
}
}
}
}
} //The code gets closed
- we create the wooden structure by creating the cube shape, and attach each bar with nails. We use the following measures: 5 sticks of 10x1x1, 2 sticks of 35.5x1x1 and 3 sticks of 14.5x1x1 and the wood platform of 35.5x15x0.3cm
we paint black our structure made from wooden sticks of different sizes, to make it a dark structure.
we add the electronic components with silicone and here you can see the structural drawings of it.
we join our components with soldered wires to a breadboard and connect it to our arduino (the code)
Downloads
add the fabric
And this is the final result