jcs1738
jcs1738
Jason Streeter - IGME 470
3 posts
Don't wanna be here? Send us removal request.
jcs1738 · 5 years ago
Text
Final Project - Arduino MIDI Controller
Project Requirements
For our final project we had to create an interactive experience that incorporates bi-directional communication between an Arduino and some other board/computer/controller. For my project, I’m using four cap-sense inputs and two potentiometers to allow users to send MIDI data over the USB port to a computer. This allows users to use this MIDI controller to record their own MIDI tracks, or play on a virtual synthesizer. The computer can also communicate MIDI data to my controller as well, and the speaker will play any MIDI input to the Arduino after pressing the push button to change input/output mode. This allows users to play sounds or MIDI tracks through the speaker. This combined with the MIDI input from the cap-sensors incorporates the necessary bi-directional communication for my project.
youtube
Implementation
This project takes advantage of the MIDIUSB library to process MIDI data back and forth between a computer. Four cap-sense inputs correspond to 4 consecutive MIDI notes, and when they are pressed they a “note on” message to the computer for the current note. When the user releases the cap-sense input a “note off” message is sent for that same note. The two potentiometers control velocity (volume) and the note shift (octave). My program reads the value of these two potentiometers each loop, and sends the current volume and note shift along with the “note on” message to determine the specifications on how the note should play. The push button changes the mode from output to input and vice-versa, and when reading MIDI input from the computer, my program parses each MIDI message, and sends the appropriate tones to the speaker. When outputting MIDI you can play two notes at once, but sadly, when playing MIDI input from the computer, the speaker can only play one tone at a time due to the limitations of the tone library. I also developed my own small, simple library for this program, which stores data for each “key” on my controller. These MIDI_key instances track information such as if the note still paying, what the key’s default note should be, the key’s pin number, and other things. With all this combined my controller allows two way MIDI communication between a computer, and with a DAW (Digital Audio Workbench) like Audacity or Ableton, you can use this controller to record MIDI tracks, and play the same tracks through the speaker on the Arduino.
Challenges
The first challenge I encountered while developing this project was working with the MIDI data sent over the serial port. It was fairly simple to get my cap-sense inputs to send the MIDI data I wanted to the computer, but it was much harder to parse the incoming MIDI data to play out of the speaker. There is not a lot of documentation online for the MIDIUSB library, so the structure of the data being sent to the Arduino was unknown to me. It took a long time of searching and trial and error to get the incoming MIDI data to properly output to the speaker. My next and biggest challenge was trying to get my accelerometer working. I wanted to tape the accelerometer to a drumstick to act as a separate “key” so when you play the drumstick in air, or hit it on something, it will send a note over MIDI to the computer. I went through a lot of trial and error but I couldn’t get the accelerometer working, as I could not ever get the output data I needed. I still don’t know what I’m doing wrong, but hopefully this is a challenge I can overcome fairly easily with more research into Arduino and how it uses accelerometers.
Future Improvements
There are many ways I can improve my MIDI controller, and with enough work I could make it a full fledged MIDI keyboard with options for pitch bend, reverb, different instruments, and many more. However, the first improvement I would make is getting my accelerometer working, as I think it would be an interesting tactile experience to use a drumstick as you would on a drum set, but by hitting it on anything to get MIDI input to the computer. I could also add more more speakers so the outputted MIDI data from the computer can be played accurately, because as of now it can only play one tone at a time. Another way to get multiple notes from the incoming MIDI data to play at once on the speaker would be to use a different tone library that supports multiple clocks running at once, or to use a different speaker that can directly output MIDI data. If I had included more inputs such as switches or sliders, I could also fine tune the MIDI data being sent so the controller could effect more sound variables. There is a lot more that can be done with the basic groundwork I’ve established, and there is much more functionality that can be implemented when working with MIDI data. All it would require of me is more research into the MIDI protocol, the MIDIUSB library, and the specifications of the Arduino and speaker I’m using.
0 notes
jcs1738 · 5 years ago
Text
Project 2 - Arduino DJ
Project Requirements
This project required us to build an interactive Arduino experience that uses at least one type of audio component. To meet these requirements I used two speakers, but also a servo to serve as a sort of “drum track”.
youtube
Implementation
My Arduino DJ is controlled by two capacitance sensors, two potentiometers, and a push button. The capacitance sensors each correspond to one speaker, and pressing them will play a tone on that speaker. The tone of both speakers is controlled by a potentiometer, and can be changed while a speaker is holding out a note, resulting in a cool synthesizer effect. The servo “drum track” is controlled by the push button and the other potentiometer. The potentiometer controls the speed of the servo, and the push button changes the beat the servo plays. Currently, there are only two beats to switch between: simple quarter notes or a triplet beat, but changing the speed of the servo offers many possibilities for a drum track you can play the speakers over.
Challenges
Besides coming up with an idea for this project, which wasn’t easy for me, I only had a few real challenges. The first was getting the servo to act as an accurate drum track that can stay on beat. Some more complex beats I tried would either make the servo stutter, or did not keep a steady rhythm. I decided to only include two simple beats, and I tracked the current millis() and used a state machine to detect when to move the servo. Even with these two things in mind, it was still difficult to make any other beat that wasn’t just a constant note at the same speed over and over. Making the triplet beat required me to detect multiple different states and mess around with the timing to get it right. My other major challenge was getting the speakers to both play at the same time, which I couldn’t accomplish unfortunately. I found out using the tone() function was probably why only one speaker would play at a time, but even when I tried to brute force different tones by counting micros() and using a state machine, I couldn’t get it working properly. Eventually I decided only being able to play one speaker at a time wasn’t going to make or break my project, and you can still change the tone while the speaker is playing by using the potentiometer.
Future Improvements
There is a lot I can do with this project in the future. Besides adding more drum beats that you can switch between, or getting both speakers to be able to play a note at once, I can add lots of different components to really flesh out my “DJ table”. If I had another potentiometer I could have both speakers be able to play different notes instead of both of them using the tone mapped from the one potentiometer value. I could also make a full fledged drum track if I had more servos, one servo being the “bass”, another being the “hi-hat”, and a third being the “snare”. I’m sure I could add all kinds of components that either output audio or make some sort of sound and make them controllable. If I do decide to keep adding components, with the right ones, I could make a whole variety of different “instruments” playable, and have a proper DJ table.
0 notes
jcs1738 · 5 years ago
Text
Project 1 - Programmable NeoPixels
Project Requirements
For this project we needed to use 2 or more Arduino inputs to control some LEDs. For my project, I decided to create a programmable NeoPixel strip, which uses a potentiometer and two push buttons to change the color of a specified pixel in the strip. Using these inputs, you can program the strip to be any color, or combination of colors, that you want. (In my example video I only set the strip to one color, but in this image you can see you can create any combination of colors you’d like.)
Tumblr media
youtube
Implementation
The pixel strip starts with all the pixels set to the color white. You begin with the with the first pixel in the strip being the one that is currently selected. Using the push button on the left you can move up the strip by one pixel at the time, looping back to the first pixel once the end is reached. The currently selected pixel is indicated by whichever one is flashing on and off. The RGB LED starts as red, indicating that the color you are manipulating for the current pixel is red. To change the color you want to manipulate, press the push button on the right. You can cycle through red, green, and blue, and the RGB LED will be lit up with the color that is currently selected. To change the value of whatever color is selected for the current pixel, you can adjust the potentiometer. The POT value is mapped between 0-255 to correspond with the color value of the selected color for the current pixel. To save the color you have set for the current pixel, just switch the pixel with the left button, and you will now be able to change the color of the next pixel. The current RGB values are saved from whatever the color was set on the last pixel, allowing you to quickly update the whole strip with your custom color by just cycling through all the pixels once you have adjusted one to the desired color.
Challenges
The first challenge was getting the buttons to cycle through the current pixel and color smoothly, without being able to hold the button down and quickly loop through them. I created a variable for each button that controls whether the buttons can accept input, and they are set to false as soon as a button is pressed, and back to true once the button is released. I then stored state variables for the current color and pixel to track which color and pixel is currently selected. Another problem was storing the color values for the pixels as they blink or as you switch between them. I had to use bitwise operators to extract the RGB values from the current pixel’s color, and save them in uint8_t variables to be manipulated or set for different pixels down the line. Besides those two problems, most of the other code was easy to implement, and just required me to create state machines to process input and output separately. I also had to create a state machine when storing the user’s custom color based on the currently selected color by taking the POT’s value for only a certain color channel depending on the currently selected color.
Future Improvements
One thing I can do to improve on this project is have the user manipulate the currently selected color using a different type of input. As of now, the potentiometer can’t reset each time the currently selected color is changed, and this makes it annoying to create a custom color as each time you switch the current color channel, the value of that color will be what the potentiometer was set at for the previous one. In the future, I can potentially find an input that is also in a resting state, and moving it up or down will lower or raise the value of the current color channel. This way, as you switch color channels, the value of the color for that channel stays at what it was previously set at, and doesn’t overwrite with the current value of the POT.
1 note · View note