Distance Sensing LED Clock

by mullencn in Circuits > Microcontrollers

300 Views, 3 Favorites, 0 Comments

Distance Sensing LED Clock

IMG_7128.JPG

This Instructable guides you through how to create a distance-sensing LED clock using Neopixel LED strips and a distance sensor. This clock uses LEDs to tell the time in place of moving minute and second hands, and uses the distance sensor and speaker to speak the time aloud when someone walks in front of it. It also features a built-in alarm, which will light up and flash red when it hits a specified time. to see a video of it in action, watch here!

Supplies

  • Adafruit Circuit Playground Bluefruit (CPB)
  • You will also need a Micro USB cable to connect to your computer and upload code to the board
  • 2x 1/2 Meter 30-Neopixel strips with Alligator Clips
  • This could be changed out for a 1 meter 60-Neopixel strip, with some modifications to the code. This guide doesn't include those modifications, but feel free to tinker with it if you're making your own!
  • Adafruit VL54L1X Distance Sensor
  • Speaker
  • Stemma Qt to Alligator Clip connector
  • Battery Pack
  • Wire
  • 4x Alligator Clip ends
  • If using class-provided materials, Don't cut the ends off of these! If you aren't able to source other alligator clip ends from other wires, these may be replaced by bolting in the ends of the wires to the CPB.
  • 1/4" Clear Acrylic - sheet must be approximately 16" x 16" or larger
  • 4x 1/8" Baltic Birch Wood - sheets must be approximately 16" x 16" or larger
  • Two of these sheets may be replaced with a single 16" x 16" or larger sheet of 1/4" Baltic Birch, alongside two sheets of 1/8", by making some modifications to the guide. This guide does not include these modifications, but feel free to tinker with it if you're making your own!
  • 4x 3/8" blocks of wood
  • So long as one of the dimensions of the rectangular blocks is 3/4", the others aren't strictly required to be a certain dimension. The ones I used in this guide were approximately 3 1/2" x 1 1/4" x 3/4"
  • Clear Tape
  • Electrical Tape

Prepare Necessary Materials

IMG_7098.JPG
IMG_7099.JPG
IMG_7100.JPG

Before we can begin putting the clock together, we need to cut out the sections of wood and acrylic we need in order to build the clock, perform any necessary modifications to these pieces, and finally prepare some sections of wires. First, you will need to laser cut the four sections of 1/8" Baltic Birch and one section of 1/4" Acrylic. You may laser cut these using the supplied files. The clock circle file needs to be cut out on the piece of Acrylic, as well as three of the pieces of Baltic Birch, while the clock base must be cut on the remaining section of Baltic Birch. Once these sections have been cut, small modifications can be made to some of the wooden pieces.

With the wooden pieces cut, we will need to take two of the wooden clock circles and cut a small segment out of them. This segment will later be used to pass wires through to the distance sensor. In order to perform these cuts, I used a bandsaw, although they may also be performed with a hand saw. Once these are done, we can move on to modify the clock base. Here, we will need to drill two small holes on opposite sides of the base, on the inside of the engraved ring. These will later be used in order to run the alligator clips for the NeoPixel LED strips, as well as one being used for the wires for the distance sensor. In addition to these two holes, a third hole will need to be drilled outside of the center of the design on the base. This will be used in order to pass the aux cable from the speaker to the back of the clock. Similarly to the bandsaw cuts, I made these cuts using a drill press, though you may also use a traditional drill if you do not have one available.

Once these pieces have been cut and then modified, you can move on to assembling the clock from these parts.

Assembly

IMG_7101.JPG
IMG_7129.JPG

For the assembly of the clock, I primarily used hot glue. Some sections may be done using wood glue or superglue instead, however, this will take longer to dry and may need to dry under other conditions. If you recreate this using another form of glue, plan accordingly.

To begin, first glue the two wooden clock circle layers with cut out slots to the front of the clock base. You should line up the two slots with one of the holes made on the opposite sides of the base. This will become the bottom of the clock when done with assembly. Next, glue the four 3/8" wooden blocks to the back of the base, placing them roughly around the outer edge of the base. Once these are all glued in place and all glue is dried, use a nail gun with 3/4" nails to secure the blocks to the rings and base. Place two nails in each block, making sure that all nails go through the block, base, and rings.


With the nails placed in the base structure, glue the acrylic circle on top of the two wooden circle pieces. Once this is attached, we can run the stemma QT cable and begin to place the NeoPixel LED strips in place around the edge of the circle. Run the stemma QT cable through the hole on the bottom of the base and through the slot to the outside of the circle, with the alligator clips out the back of the base. To attach the strips, orient them so that the alligator clips each line up with one of the holes drilled around the outside of the ring, with each strip going to the left relative to this point. Run the alligator clips through the holes on the base to the back of the base. The strips should wrap around the rings from the inside. Once they are in place, secure them with clear tape to the base and acrylic ring. Once these are secured, you may glue the final wooden circle on top of the acrylic ring. Next, you can glue the speaker to the center of the board, running the aux cable through the hole to the back of the board. Finally, glue the distance sensor to the top ring, over the segment with the slot cut below. This will allow it to reach the Stemma Qt connector.

Wiring

IMG_7129.JPG

With the clock assembled and the necessary wires passed to the back side, you can begin connecting the wires to the CPB, and splicing any additional wires to make additional connections to the CPB easier. Before running any connections, we want to first prepare our wires. There are 4 segments of wire that need to be prepared: one for 5v, one for Ground, one for data to the top LED strip, and one to the audio signal on the speaker. The wires for the audio signal and data for the top LED strip can both be prepared the same way, by soldering an alligator clip end to a segment of wire. You will need the other end of this segment to be stripped, so I would recommend doing this now. Cover up any exposed solder joints with electrical tape. To prepare the 5v wire, prepare a length of wire to run from the top to the bottom of the clock, splicing on one additional segment of wire. Solder another alligator clip end to this spliced segment, and cover any exposed joints with electrical tape. Lastly, to prepare the ground wire, prepare a length of wire to run from the top of the clock to the bottom, splicing on three additional segments of wire. Solder an alligator clip to the end of one of these segments, and electrical tape over any exposed connections. The ends of each segment of both the 5v and ground wires without alligator clips will all also need to be stripped, which I would recommend doing now.


With the additional wires prepared, we can begin wiring the rest of the clock. First, connect the CPB to the Distance Sensor, via the stemma QT cable (due to this cable being towards the bottom of the clock, I would advise wiring this with the CPB at the bottom of the clock). Connect the yellow cable to SCL, the blue cable to SDA, and the red cable to 3.3v. Don't connect the black cable yet. Next, connect the white cable from the bottom LED strip to the A2 pad on the board. Then, connect the alligator clip from the ground wire to the GND pad. Connect the black wires from both LED strips and the stemma QT cable to the segments of this wire, taking the remaining segment and wrapping it around the base of the TRS connector of the speaker. Then, connect the alligator clip from the data cable for the top LED strip to the A1 pad, and connect the white alligator clip from the top LED strip to this wire. Next, connect the audio cable to the audio pad with the alligator clip, wrapping the other end of this wire around the center ring of the speaker's TRS connector. Finally, connect the alligator clip of the 5v wire to the VOUT pad on the CPB, connecting the two ends of this wire to the red wires on the LED strips. Once all of these wires are connected, attach the CPB to the back of the clock using tape. If using battery power, also attach the battery pack using either hot glue or the clear tape, leaving the on/off switch accessible. The clock is now built.

Coding and Setting Times

Now that the clock has been assembled and all wires have been run to the CPB, it is time to program in the code that will make the clock run. The supplied code contains nearly everything needed in order to get the clock running as-is, although there are a couple of extra steps needed before turning it on for the first time. Specifically, set the time the clock will start at in hours, minutes, and seconds with startHrs, startMins, and startSecs, respectively, as well as if it is AM or PM by setting the PM variable false or true. Set the alarmHrs, alarmMins, and alarmSecs to what time you would like the alarm to go off. Make sure that you also download the sound file, available at the link here, and save all files to the CPB. If storing them in a folder, rather than just on the CPB, make sure to change the path variable to specify this.

The code primarily works by sleeping by 1 second each time the main loop is run, in order to count up by one second each time. If it is the first loop, it will initially set the current time as the starting time. Otherwise, each time it increments by one second, it clears the strip by changing all colors to black, before adding one to the seconds. It then performs the necessary calculations to account for 60 seconds per minute, 60 minutes per hour, and 12 hours per half day. Afterwards, it lights up the pixels according to the current number of seconds, minutes and hours. Lastly, if the distance sensor detects something in front of it, it will speak the current time, and increment the time by the number of seconds the sound plays for, and if it is the alarm time, then it will flash the lights red and play the alarm sound (in this case, a scream), again incrementing by the length of the sound. It then loops back to the start, to begin the process again.

Downloads