Tilt With Light Bulb

by kayleeconkl in Circuits > Arduino

109 Views, 0 Favorites, 0 Comments

Tilt With Light Bulb

Arduino Project Tilt sensor with Light bulb.png

My escape room puzzle follows a missing ghost light bulb in a hunted theater. The end of the escape room puzzle leads the player to a chest that contains the light bulb. My Arduino puzzle acts as the top of a chest, and as the chest tilts open, the light bulb will turn on!

Supplies

1 Arduino

1 USB cable

1 Tilt Sensor

1 Light Bulb

2 Resistors

7 Cables

Setting Up the Code

For my escape room, you will need to use this code in Arduino.

This code tells the Arduino to measure the degree of tilt that occurs, which then signals the light to get brighter.

This can also be found in the Code Button

int tilt = 2; // input pin
int led = 13; // output pin

void setup()

{pinMode(tilt, INPUT); // tilt sensor

pinMode(led, OUTPUT);}

void loop()

{int reading;

reading = digitalRead(tilt); //tilt output

if(reading)

digitalWrite(led, HIGH); // brightness at MAX

else

digitalWrite(led, LOW); // brightness and MIN }

Setting Up the Hardware

For this setup, you will connect a cable from Arduino Digital Pin 2 to H16.

Connect another cable from Arduino Digital Pin 13 to F8.

Connect a cable from a Ground Power Pin (GRD) to the Negative hole near A1.

Connect a cable from the 5V Power Pin to the Positive hole near A1.

Add another cable connecting +9 to A9.

Add another cable connecting -16 to A16.

Add the final cable from +17 to the +17 on the opposite side of the board.

Next, add the two resistors from E9 to G9, and from I16 to +16.

Add the Tilt Sensor to D16 to G16.

Lastly, add the Light Bulb to H8 and H9.

Playing the Puzzle

For this puzzle, click the Start Simulation button and click on the green tilt sensor. A draggable element will appear. Drag the element up and down and watch as the light turns on and off.