The piano works fine, but for some reason there is a large delay between the Arduino and p5 and it is not very responsive. I did get one key to work very well in the test trial but forgot to record it.
Since the first part was almost completely my code and the final part was all my code I decided to keep this part in and I just really liked how it looked.
For the last part I mad a program that could tell if you were playing Mary Had a Little Lamb properly and would slowly draw a lamb for you. I put the code in to hook it up to the physical keyboard but the keyboard still isn't working that well so I left it commented out. I drew the lamb myself and did like a stop motion animation style using Illustrator.
But it wasn't doing anything. I made them in to three seperate codes because the way they were set up it was easier to do that some had the background withdrawn and it would have been a lot with all the sound files and stuff to add in. It is doable but I like it better as three programs. Since the physical keyboard doesn't work that well I also had built in using the computer keys as keys and layed it out the same as a piano. In the videos you won't hear the oscillator because you can only hear it with ear buds.
Here is a link to all o my code.
I originally built 13 keys but was having difficulty with the shift register so I left it at 8 and didn't use sharps and flats. I got the keyboard to work but forgot to press enter so it was stuck in oscillator mode which doesn't work without headphones I also went back and fixed it so everything else like rain and blocks works for the physical keyboard as well.
I finished building the actual keyboard and am going to use this code for the Arduino. I think I am just going to use the 8 main notes and skip the sharps and flats, because I would have to add more keys and inputs. I may however try using pitch to achieve those half steps, but it depends on how well that works. I have not had much time to actually code for it but I have continued experimenting with the code I put up last week. Which can be found here.
I just made a fun photo booth where you can take pictures in red, green, blue, black & white, distorted colors, or normal mode. Then you can also make the little pictures be in video mode so they take the live feed instead of an image. I added a clicking noise to when the picture is taken.
I haven't made that much physical progress in my project yet. I am thinking about making a keyboard by using wood, springs, and copper tape to close the circuit, but I don't know how to use that as input. I have also looked at the p5 sound library and will probably use freesound.org to get piano sounds. I want it to be a functional keyboard, but don't want it to be more of an experimental project, so it doesn't need to be played like a real keyboard. I also built the circuit for the keyboard in the Arduino book. I still need to research how to use the input, but I think the p5 side I get pretty well, but am going to look at The Nature of Code to try and see if I can incorporate noise into the project. If this is too difficult I might change the project to use singing to the computer and it creating a visual based on pitch, length of note, and volume. I will figure this out by Wednesday. I don't want it to be completely computer based, so I would rather there be a keyboard or your voice.
For part of another class I went to see Teknopolis and one of the interactive installations was a simple touch keyboard with a display, the guide said it was built with an Arduino.If you watch the video on the home page it's at the 6 second mark. I was not very impressed with the display, but really liked it as an instrument. The Arduino Projects Book has a simple button keyboard project, so I want to see if I can expand on that project and use the inspiration from the exhibit to create a keyboard I am more satisfied with. I may need to get a bigger bread board to make a larger keyboard, I may also look in to using a different sensor other than a button, the one at the exhibit just used human touch to complete the circuit, so I may look in to that as well.
For this assignment I used a potentiometer to control how many balls were bouncing from my last project. I mapped the values from 0 to 10, and added a delay so the balls wouldn't change to fast. It takes away balls if it is moving to the left and adds if it is twisted to the right, this may be different if you plug your potentiometer in with the positive and grounded ends switched because I used the difference between the last and current number. However depending on how fast it registers the balls don't always show up as expected.
So I started this project similar to the last one. I first made the Color Mixing Lamp from the Arduino Projects Book. Then I decided to switch out the photo-resistors for potentiometers so I could control the colors and the brightness better. Then I decided to add a switch just to make it more like a regular light. The code isn't that much different than my last project but it does use both analog(potentiometers) and digital sensors(the button). However for some reason I couldn't get the timings to go off. It is supposed to turn on when you press the button and allow you to mix the red blue and green while you hold the button down. Then after 10 seconds it should blink at the color that you have picked and change if you wish to continue turning the potentiometers. Then after another 10 seconds it should start fading out then turning back on then fading out. At this point you can no longer change the color with the potentiometers. Finally after another 10 seconds it is supposed to turn to red. I was sort of seeing if I could turn my project from last week into one with just one LED and more sensors. In the video I put a small piece of paper over the LED just to make it easier to see the color of the lamp. Since the timing wasn't working I wrote smaller blocks of code in different sketches to show what it would look like had it worked.
The potentiometers are connected in parallel to the power source through the switch which is why they don't work and the light doesn't turn on unless the button is pressed. I connected them in parallel so they would get the same amount of voltage. I could have put the resistor in series with the button, but I had added the button near the end, so I forgot to simplify the circuit as I went, but it would make it look less complicated, it still has the same functionality though.
Here's the link to my code.
For this assignment I decided to use the photo-resistor, because its a switch that you can turn on and off again, and you can play with how long the light stays on for. I started by building the Color Changing Light from the book and then making it simpler so I could write my own code. I decided to use two LEDs and design it sort of like a timer. The green light turns on when there is enough light, and then after 10 seconds it blinks a little and if you don't turn it off then, then it switches off and the red LED turns on. Then if you cover it both go off again. It can be repeatable too. I decided to write the code so that the LED didn't fade on and off like it usually does with the photo-resistor because I wanted a more responsive switch. I did this by watching the output of the photo-resistor and picking a number for when the LED would light up. I made the time interval pretty short just so it would be quicker to film. The LEDs also turn off whenever there isn't enough light, not just when it finishes it's cycle. For the code it was all if statements, but I probably could have used a while loop instead.
First I decided to build a simple motor with a battery, magnet, and copper wire. The motor causes the copper wire to spin around. I used this to complete the circuit, and cause the light to turn on. The circuit was really simple and just used a LED light, two AA batteries( they are 1.5V each), and the motor. I used the bread board to make everything in series. Taped two batteries together since they are in series and are both facing the same way the voltage builds up instead of cancelling out. And since the source voltage only adds up to 3V there is no need for a resistor. Then the rest is connected in series and then I left a break in the circuit to be closed when the motor spun the wire around to fill the gap. The motor is a simple physics trick and works because an electromagnetic field is produced, and the wire is also carrying a charge and so a force is induced and pushes the wire around in a circle. Ideally I would have made it so the motor would just brush up against the wires at the same moment so the light would flicker on and off by itself as the motor continued to spin the wire around, but it was a bit difficult as the wire was difficult to balance on the battery and to space the connecting wires perfectly.
This is how the motor works.
This is how I set up the circuit.
This is my project in action.