Phase 0: Idea Formation
For our final Object project, my partner Allison Roten and I decided to create an electric piano. We planned for the piano to have 8 keys (able to play one full scale from C to C) and a potentiometer to change the octave. We scratched this potentiometer idea pretty early on, realizing we had way too much work already on our plate without this addition. We planned there would be Neopixels inside the box that light up a certain color when you play a certain note, under the corresponding key. The top of the piano would be laser cut frosted acrylic keys so you could see the lights change from white (so you know the piano is on) to a certain color under the key you are playing, so the user knows they pressed the key. There would be a speaker hole laser cut in the front of our wooden, laser cut box. Our keys would trigger the Neopixels to change and the sound to play by copper tape connected to a wire on the box and on the bottom of the key. The keys would be hanging about an inch from the edge of the side of the box, and when you press the key down, the circuit is completed. We stayed true to our original plan and created exactly what we intended to, though it was much more challenging that we anticipated.
Phase 1: Prototyping
To start the task of building an electric piano, my partner and I started by prototyping. We first built our circuit with one light connected to one button and wrote code to make this circuit work as we wanted, by having the light be white and change to a color when the button was pressed. We then connected the same circuit to our Adafruit Audio Shield v1.1 and wrote code to get the one button to play one sound. We chose this Audio shield because it would play a certain sound we saved onto an SD card, triggered by a button press. We felt we could get the best sounding piano notes using this shield since the sounds were saved on an SD card. We ran into a lot of issues trying to get the sound to turn on, and went to our teacher, Arielle, for help. She pointed out that we didn't have the shield plugged into the Ardunio right, and once we plugged it in correctly, everything worked as it should, first crisis averted!
Phase 2: Getting the Lights to Work
Our next step was to get the lights to work by themselves. We thought the best way to go about using the Neopixels would be to use 16 Neopixels on each side of the box. Our plan was that there would be 2 Neopixels on each side of the box per key (so four Neopixels per key total) so the box would be lit up form both sides and diffuse the light under the frosted acrylic in an aesthetic way. We first thought the best way to go about this was to solder each Neopixel separately, meaning we would solder 32 individual Neopixels, which then means we would solder 96 individual wires (3 wires per Neopixel). And this is exactly what we did. We then went to Arielle again because we realized we did not have enough pins in the Arduino for all of these Neopixels and we were looking for advice on how to move forward. She asked why we didn't just use two strands of 16 Neopixels (one strand for each side of the box) and we looked at each other and had no idea why we didn't do that in the first place. So from there we scratched the 32 individually solder Neopixels (all those hours of work for nothing) and soldered two strands of 17 Neopixels (one extra pixel in case we made a mistake). We connected 8 pre-made buttons to these two strands of Neopixels. After a lot of writing and rewriting code and with the help of Jack Marty, we finally got the strands of Neopixels to respond simultaneously to each button press; the Neopixels light up white when plugged in and when one button is pressed, two Neopixels light up on each strand, in ROYGBIV order from left to right.
Phase 3: Getting the Sound to Work
The next step was getting the 8 buttons to trigger the sound to play. We had a lot of difficulty in this step of the process. After a lot of failed tests, we realized our Audio Shield was taking up too much power and too many pins on one Arduino, so to get the speaker to play sound, we had to use two Arduinos and serial communicate between them. Once we got the two Arduinos to serial communicate (after some difficulty which we were helped through by Jack Marty), we finally got the buttons to trigger a sound to play through the speaker. We were able to get the sound to play by itself but problems arose when we tried to connect the buttons to the sound and the lights. Although the sound did play, it now didn't know when to stop playing. We ran through a lot of debugging for the code and ran into a lot of other issues along the way with the sound either not playing or not able to stop playing correctly. This part of the process was the hardest part of the whole project by far and took up the most time and needed the most outside help. We went to Jack Marty, who helped a lot. We went to Caleb, the Object TA and Mary West, the interim professor in place of Arielle and they weren't able to debug our code. The people who helped us get the lights and the sound to respond correctly to the buttons were the two graduate students who had been helping out in the classroom after Arielle went on maternity leave. I unfortunately forget their names, but they were amazing and life savers. We wouldn't have been able to finish this project without their debugging support and explanations on what was going on with our code. Although we did debug the code, the sound didn't respond perfectly to a button press; there was a bit of a delay in the sound playing and if you held the button down for too long, the sound would play again. This made the piano not have the best response rate, but it was playable now which we were really excited about and so thankful we finally figured out the problem after 40+ hours put into working on this project up to this point in time (we pretty much lived in the BTU for the weeks we were working on this project).
Phase 4: Creating the enclosure
Creating the enclosure was a nice break from debugging code, which is what the project had mostly consisted of up until this point in time. We had to re-cut the acrylic keys a few times over at different lengths to get the perfect amount of sturdiness yet bendability in the keys. We glued our box together with wood glue and cut out a shelf and supporting legs to put inside the box to hide the Arduino, speaker and breadboard etc, from being seen through the acrylic. We also made sure to include two holes in the back of the box so wires could be fed into the box to power the Arduinos and the speaker.
Phase 5: Putting it all together
We ran into some trouble again when we put the hardware into the box and started making our own keys. We first prototyped the buttons we made out of copper tape to make sure they worked. We got all of the pre-made buttons replaced with our own wires and tested to make sure each circuit worked. When completed, we put it into the box and tested it and it still worked. We're not sure what exactly changed to trigger the circuit to freak out, but it did. Each button worked except one button, which being triggered when our hands were close to the circuit but not when our hands were far away. It was very strange. We took our circuit out of the box, replaced each wire button with the pre-made button, tested all the wires and replaced them (to see if it was a faulty wire), but the problem was still occurring. We tried everything we could think of with no luck. I brought the circuit back to the two grad students who had helped us the first time and together we figured out it was a simple power issue...the power from the computer was being plugged into the wrong Arduino, though we didn't know beforehand there could be a wrong Arduino to plug the power into! Once we fixed this problem, we put everything back into the box, and re-replaced each pre-made button with the wires. This was really hard as there were a lot of wires jammed in really close to each other, enclosed in a box so it was hard to see and put each wire in the correct spot to connect them as buttons. What helped most was keeping things really organized and labeling our wires. We also ran into trouble when connecting the wires to the copper tape on the wood and on the keys. The copper tape didn't want to stick to the wood, but I discovered after trial and error that if I cut the tape in really small strips, just big enough to stick to the surface of the wood and not bend over the side, it would stick much better. The wires didn't want to stay in place on the keys either, they kept falling out of the copper tape. So after some trail and error, we figured out the best way to get them to stick was to put a piece of copper tape on the key , all cut the same size and placed the same on each key so they were aesthetically pleasing to the user. Then we took another piece of copper tape, wrapped it around the wire, and sandwiched it between the copper tape on the key and another piece of copper tape and secured it by hot gluing around the wire, making sure to not get the glue on the wire because then the wire would be insulated and the connection wouldn't be able to be completed. After we got all of these wires cut the correct length and connected on the box and to the keys, we put the top on and plugged in each key wire into the breadboard, which was difficult with so many wires already connected to the breadboard so close together. We finally got it, though we had to re-plug in a few wires a few times because they kept falling out. We then tested to make sure everything worked and then put the top on, put the shelf in and taped the Neopixels to each side of the box. We plugged everything in and tested again and had to make some adjustments, but everything worked! We decided the best way to secure the top onto the box was to tape the two back sides of the top down on top the box, so we could easily take the top off and adjust the inside circuitry/speaker if need be.
Phase 6: Documentation
We finally finished this piano, after 60+ hours working on it. Even though it didn't work perfectly and we would still work on debugging the sound response if we had more time, it worked to a point we were happy with, especially after being told we wouldn't be able to get it working at all many times. I am really proud of us for sticking with this project and completing it to the point where it works and looks (relatively) beautiful. It feels great to have a final product that works and I am happy and proud to show off!
For the first part of this lab, we were tasked with driving a DC motor in both directions. When the circuit is given power (plugged into the computer), the motor turns on. When the switch is pushed, the motor changes the direction it spins. This happens so fast its hard to see in the video, so you have to look hard! The hardest part of this lab was getting the motor to spin in both directions. I was having a lot of issues getting the motor to respond to my switch, but realized eventually after checking my circuit and code over multiple times, that the problem was my code. I used the analogWrite() and analogRead() functions instead of digitalWrite() and digitalRead(). Once I switched this in my code, the circuit worked perfectly! It was also interesting and a new challenge working with the H-bridge. I got the H-bridge hooked up correctly the first time which was exciting, but I had to make sure I looked at and follow the schematic closely and build the circuit slowly to make sure I didn't mess anything up. I liked this part of the lab, it was exciting driving a motor for the first time!
Part 2 of this lab seemed much more manageable after getting through part 1. The hardest part of this lab was building the circuit as there were so many connections to make and a lot of wires to deal with. The circuit got quiet confusion quiet fast. Once I got all the connections together, I wrote my code pretty easily and connected the Ardunio to my computer. It didn't work at first because I forgot to include the stepper library, but once I added this to my code, the stepper motor worked correctly right away!
For this lab, I decided to use two potentiometers to change the green (left potentiometer) and blue (right potentiometer) vales of a circle. I made the background change to a random color by randomizing the values of green and blue between 0 and 255 each time you pressed play on p5. The potentiometers controlled the green (g) and blue (b) values of the circle and if you got within 10 units of the correct g or b value, a notification pops up at the top of the canvas saying "Left (or Right) Controller Correct!". I controlled this by mapping the potentiometer values to read as a value between 0 and 255 and compare to the value that p5 spit out for the g and b background value. I had to use the int() function and say the value is correct within 10 units, to make it possible to actually match the value of the background. It would've been impossible to match the value dealing with decimals and even one value at a time. I set the red value to 0 in both the background and on the circle, so the player only deals with the green and blue colors. When you get both values correctly within 10 units of the background values, a message pops up that says "You win!" and a LED light on the breadboard lights up.
I really enjoyed this lab! It was fun to make controller for a computer game, I felt like I entered a new realm of physical computing. I love working in p5.js. I took Code 1 with Joel Swason last semester and we worked entirely in p5. I really like working in it and know it well, so it was nice that the coding part of this lab came easy to me, as the Ardunio coding comes a little bit slower to me because it is a new system. The most challegne part of this lab was getting the Arudnio code to talk correctly to p5 and make sure the p5 serial monitor was up and running (I couldn't figure out why nothing worked...only to realize my serial monitor wasn't open!) I feel like I learned a lot and really enjoyed myself throughout this lab! I also felt like this lab made a lot more sense to me than previous labs which I give credit to understanding p5 previously and the last lab being such a challenge...it helped make this one seem easier and more understandable and much more manageable!
For Part 1, I used two LED's in series, with 100 Ohm resistors on each. I connected a Potentiometer to control the first LED and a Pressure Senor to control the second LED. The Potentiometer did not a resistor but I had to use a 100 K Ohm resistor when connecting the Pressure Sensor. I had a bit of difficulty getting the separate sensors to control the separate LED's, both sensors kept controlling both LED's to some extent. I went through some trial in error in my code to make sure everything was separate and I ended up doing something, I don't even know what, that made it suddenly work fine! It was interesting making a circuit with this many parts, it was overwhelming at first but once I broke it down into sections, I was able to complete this! It made the rest of the circuits in the other parts of the lab seem much more manageable.
For the second part of the lab, I first soldered wires to the + and - ports of the speaker. I then connected the other ends of these wires to pin 8 and to a 100 Ohm resistor that was connected to ground. Then I connected two flex sensors in series to pin A0, power and ground. I wrote my code and plugged in the arudino and it didn't work! I changed my speaker to pin ~9 and it still didn't work. After staring at things for a while and messing with my code and rechecking my circuit many times, (Nate and) I finally realized my breadboard wasn't actually plugged into ground! Once I fixed this, the speaker worked perfect!
For the last part of this lab, Allison Roten and I worked together. We decided to use two LED's in a breakout board as our digital output and a speak for our analog outputs and a Press Sensor and Potentiometer for out analog inputs. We looked at our circuit for a while and thought about how we make these inputs and outputs into a creative shape. We decided on a little monster box! We decided to laser cut a square box (4.6 inches HxWxD) and laser cut out eye holes (for the LEDs), a mouth (over where the speaker will be), a whole for the nose (where the potentiometer will be), and a whole for the hand (the Pressure Sensor). We used 1/4 inch Baltic Birch. The building of the box was prety easy, everything slid right into place. We taped the inside sides of the box together for extra stability. The box came out a lot cuter than we thought it would! We were very happy with our final product.
For the Digital I/O, I started by making two circuits; one LED and one switch, both connected through the Ardunio. Once I got this working, I recreated the same two circuits on a different part of the breadboard. The switch part of this was a little harder because I used a different type of switch to challenge myself. I couldn't get this second part working for a while, and then realized I had my LED lined up backwards. Once I fixed it, it ended up working fine! The code wasn't too hard to write for this code, as it was basically the same thing repeated twice, except I changed the pin numbers, as the Input and the Output were through different pins in the different circuits. It was interesting and different working with the Ardunio instead of just the breadboard. It was helpful starting small and working my way up, it helped me understand it step-by-step.
Making the breakout board was an interesting, new challenge. I first, broke out two piece of the snap-out board. I then laid out a switch and a 22k ohm resistor on the first board and two LED's and a 100 ohm resistor on the second board. Then, I laid out the wires that needed to be put on these boards. I connected the input to the first board through the resistor, and then connected the output and ground to the corresponding spots on the switch. On the second board, I put the input to the resistor and the output to the LED's. Then, I soldered these wires to their correct spots! Soldering was a challenge, it took me a few tries to get the hang of it. I then connected these breakout boards to the correct ports in the breadboard/ardunio. I used my Digital I/O board for reference on knowing where to put which wires. I then wrote a few lines of code telling the ardunio to turn the LED's on if the switch was on "High." It worked on my first try!
Circuit in Series
The first circuit I made was the Series Circuit. First, I calculated how many amps the resistor needed to be to fit this circuit. I calculated it to need to be 50 amps. I had some trouble understand where I could put what and make each part able to connect on the bread board. I sought help from a fellow classmate who really explained how the bread board worked and where I can put what and why. This really helped me get a grasp on what I was doing and I was able to go off on my own and make this working circuit. I put everything in place and tested it by plugging it in, but it didn't work. I realized I had put the resistor in the wrong hole so it didn't line up with the LED. I tested again and it didn't work again, finding another small problem I needed to fix. I repeated this a few times until I finally got everything in the right place. I was so ecstatic when I turned the switch on and the LED's finally turned on, it was my first ever successful circuit and I felt so proud I made those lights turn on myself!
Circuit in Parallel
The second circuit I built was the Parallel Circuit. I kept everything the same except, I took the LED's and the resistor out. I recalculated the amps the resistor needed to have to work with this circuit/ I calculated the resistor should be 100 amps. I actually had a very hard time finding 100 amp resistor in the BTU lab, so I waited until a classmate was done with his and put them in mine and quickly took them out again. I got this one to work after a couple tries as well. Personally, I thought making the series circuit made more logical sense and it clicked faster for me. It was a little strange needing two resistors instead of one. The parallel circuit was a bit confusing, and it took me a minute to shift mental gears into parallel mode. But it helped a lot already having most of the circuit made from the series circuit.
I created my homemade switch by sticking two stripped wires onto two pieces of copper paper. I then stuck these pieces of copper paper on some foam paper. Then, I put two small, cut pieces of foam between the copper paper to separate them. I plugged the other, stripped ends of the wire, into the same spots as the far edge prongs of the original switch. I then taped the foam/copper/wire pieces all together, so when you pushed the center of the foam, the two copper paper pieces touched, and turned on the circuit!
For the enclosure, I started by moving all the wires to the left side of the breadboard so the LED's and voltage converter were on the same side so I could easily enclose all the wires while the LEDs and voltage converter were easily accessible and visible. I then cut cardboard out and sized it to enclose all the wires on the left side of the breadboard while making the right side flush to the breadboard. This ended up looking like a piano so I just went with it, and colored the cardboard like piano keys while covering the rest of the cardboard in tape to make it look nicer and more finished. The voltage converter is the only thing uncovered, so it is easily accessible when plugging the circuit in. I taped the homemade switch to the left side of the "piano," covering it in the same color tape so its a bit hidden and all looks like a cohesive piece.
Welcome to my progress blog for my Object course at the University of Colorado, Boulder. Enjoy watching my process as my ideas become a reality.