Study Room Timer

Instructions on how to create a timer for a study room.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Interaction Video

https://drive.google.com/file/d/12z5zQR52AXILX2AGb3EplfbmZWANZiCl/view?usp=drivesdk

Step 2: Problem Statement

Most of the time, study rooms are always taken. This happens because people like to stay in the room for much longer than they need. We have designed a timer that allows each person a total of 2 hours and people waiting the ability to request the room to be the next group in. The use of RGB on Neopixels will express the amount of time left.

Step 3: Overview of How It Works

The timer consists of parts cut by the laser cutter, 3 buttons, 1 LED, 1 potentiometer.

The Neopixels and potentiometer is wired to the NodeMCU. The NodeMCU is programmed to regonize how far the potentiometer is turned to change the amount of LED's that are lit on the circular Neopixel strip. The Request button stops the function of the Start, Stop, and Set time function. The color of the LED's on the timer inside the room is the same color of the LED lit on the side of the box. The neopixel on the side of the box represents the display in the lobby of the building to know which room is taken and how much time is left. 2 LED's are prescribed for each room, one LED represents if the room is taken and the other led mirrors the color of the LED's on the timer (green is more time, then yellow, then red for less time).

Step 4: List of Materials and Tools

Step 5: Start Building With the Breadboard

A0 to middle pin on Potentiometer

Vin to Power on Neopixel ring

3v3 to one side of Potentiometer

All grounds to Ground on NodeMCU

D1 to Request Button

D2 to Request LED

D3 to Start Button

D4 to Stop Button

D5 to resistor to Neopixel Input on ring

D6 to resistor to Neopixel Input strip

Step 6: Starting the Code

This is the code for making sure your project is working thus far. The timer should only be a couple of seconds per LED on the Neopixel Ring. Once you know it is working up until this point, all you need to do is change the time if statements below to your specified range. I will put '#Change time' on each of the time if statements that you need to change for your time allotment.

Trying the Code:

import utime

import time

from machine import ADC

import machine

import neopixel

adc = ADC(0)

pin = machine.Pin(14,machine.Pin.OUT)

np = neopixel.NeoPixel(pin,12)

pin2 = machine.Pin(12,machine.Pin.OUT)

np2 = neopixel.NeoPixel(pin2,8)

l1 = machine.Pin(4,machine.Pin.OUT)

b1 = machine.Pin(5,machine.Pin.IN,machine.Pin.PULL_UP)

b3 = machine.Pin(2,machine.Pin.IN,machine.Pin.PULL_UP)

b2 = machine.Pin(0,machine.Pin.IN,machine.Pin.PULL_UP)

l1.value(0)

def tglled(): # toggle 'request' LED function

if l1.value() == 0:

l1.value(1)

else:

l1.value(0)

x = 0

b1temp1 = 0

b1temp2 = 0

t = 0

b2temp1 = 0

b2temp2 = 0

b3temp1 = 0

b3temp2 = 0

s = 0

while True:

# This is the button that toggles the 'request' LED

b1temp2 = b1.value()

if b1temp1 and not b1temp2:

tglled()

time.sleep(0.05)

b1temp1 = b1temp2

# This is the grid

np2[0] = np[11]

if l1.value() == 1:

np2[1] = (30,0,0)

else:

np2[1] = (0,0,30)

np2.write()

# This is where we select how much time we need

if t == 0:

for i in range(-1,12):

if (l1.value() == 0):

if (adc.read() >= (85.34 * (i+1))):

np[i] = (0,0,0)

np[11] = (0,0,30)

s = (i + 1)

else:

np[i] = (0,0,30)

np.write()

else:

np[i] = (0,0,0)

np.write()

# This is the button to start the timer

if (l1.value() == 0) and (t == 0):

b2temp2 = b2.value()

if b2temp1 and not b2temp2:

x += 1

t += (s * 100)

time.sleep(0.05)

b2temp1 = b2temp2

# This button ends the timer

if (l1.value() == 0):

b3temp2 = b3.value()

if b3temp1 and not b3temp2:

x = 0

t = 0

time.sleep(0.05)

b3temp1 = b3temp2

# This is the timer

if x > 0:

t += 1

if (t > 0) and (t <= 100): #Change time

np[0] = (5,30,0)

np[1] = (5,30,0)

np[2] = (5,30,0)

np[3] = (5,30,0)

np[4] = (5,30,0)

np[5] = (5,30,0)

np[6] = (5,30,0)

np[7] = (5,30,0)

np[8] = (5,30,0)

np[9] = (5,30,0)

np[10] = (5,30,0)

np[11] = (5,30,0)

np.write()

if (t > 100) and (t <= 200): #Change time

np[0] = (0,0,0)

np[1] = (10,30,0)

np[2] = (10,30,0)

np[3] = (10,30,0)

np[4] = (10,30,0)

np[5] = (10,30,0)

np[6] = (10,30,0)

np[7] = (10,30,0)

np[8] = (10,30,0)

np[9] = (10,30,0)

np[10] = (10,30,0)

np[11] = (10,30,0)

np.write()

if (t > 200) and (t <= 300): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (15,30,0)

np[3] = (15,30,0)

np[4] = (15,30,0)

np[5] = (15,30,0)

np[6] = (15,30,0)

np[7] = (15,30,0)

np[8] = (15,30,0)

np[9] = (15,30,0)

np[10] = (15,30,0)

np[11] = (15,30,0)

np.write()

if (t > 300) and (t <= 400): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (20,30,0)

np[4] = (20,30,0)

np[5] = (20,30,0)

np[6] = (20,30,0)

np[7] = (20,30,0)

np[8] = (20,30,0)

np[9] = (20,30,0)

np[10] = (20,30,0)

np[11] = (20,30,0)

np.write()

if (t > 400) and (t <= 500): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (0,0,0)

np[4] = (25,30,0)

np[5] = (25,30,0)

np[6] = (25,30,0)

np[7] = (25,30,0)

np[8] = (25,30,0)

np[9] = (25,30,0)

np[10] = (25,30,0)

np[11] = (25,30,0)

np.write()

if (t > 500) and (t <= 600): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (0,0,0)

np[4] = (0,0,0)

np[5] = (30,30,0)

np[6] = (30,30,0)

np[7] = (30,30,0)

np[8] = (30,30,0)

np[9] = (30,30,0)

np[10] = (30,30,0)

np[11] = (30,30,0)

np.write()

if (t > 600) and (t <= 700): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (0,0,0)

np[4] = (0,0,0)

np[5] = (0,0,0)

np[6] = (30,25,0)

np[7] = (30,25,0)

np[8] = (30,25,0)

np[9] = (30,25,0)

np[10] = (30,25,0)

np[11] = (30,25,0)

np.write()

if (t > 700) and (t <= 800): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (0,0,0)

np[4] = (0,0,0)

np[5] = (0,0,0)

np[6] = (0,0,0)

np[7] = (30,20,0)

np[8] = (30,20,0)

np[9] = (30,20,0)

np[10] = (30,20,0)

np[11] = (30,20,0)

np.write()

if (t > 800) and (t <= 900): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (0,0,0)

np[4] = (0,0,0)

np[5] = (0,0,0)

np[6] = (0,0,0)

np[7] = (0,0,0)

np[8] = (30,15,0)

np[9] = (30,15,0)

np[10] = (30,15,0)

np[11] = (30,15,0)

np.write()

if (t > 900) and (t <= 1000): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (0,0,0)

np[4] = (0,0,0)

np[5] = (0,0,0)

np[6] = (0,0,0)

np[7] = (0,0,0)

np[8] = (0,0,0)

np[9] = (30,10,0)

np[10] = (30,10,0)

np[11] = (30,10,0)

np.write()

if (t > 1000) and (t <= 1100): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (0,0,0)

np[4] = (0,0,0)

np[5] = (0,0,0)

np[6] = (0,0,0)

np[7] = (0,0,0)

np[8] = (0,0,0)

np[9] = (0,0,0)

np[10] = (30,5,0)

np[11] = (30,5,0)

np.write()

if (t > 1100) and (t <= 1200): #Change time

np[0] = (0,0,0)

np[1] = (0,0,0)

np[2] = (0,0,0)

np[3] = (0,0,0)

np[4] = (0,0,0)

np[5] = (0,0,0)

np[6] = (0,0,0)

np[7] = (0,0,0)

np[8] = (0,0,0)

np[9] = (0,0,0)

np[10] = (0,0,0)

np[11] = (30,0,0)

np.write()

if t >= 1300: #Change time

t = 0

x = 0

Step 7: Finishing Touches

Now, once you are this far, you should have the working code uploaded to the NodeMCU and all of the parts wired to the breadboard. Once you have tried the code and cut any pieces you have for the exterior, i.e. laser cut casing, you may now solder the wires to the NodeMCU. The soldering is optional but may make it more secure and smaller for your casing. Here are some of the laser cut parts that we made.

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    Discussions

    0
    None
    randofo

    10 months ago

    I would have liked to see more process photos of how this is built. However, I'm guessing it's end of semester crunch time? Good luck!