Arduino based PC Footswitch
|The sacrifical banner stand||1.1 MB|
|taking shape||1.08 MB|
I am in the process of putting together a project for another hobby of mine; music. I am a trombone player, who dabbles with many many other instruments, playing in many types of bands. I play in a Band called Dennis, in addition to Westoe Brass Band, and also play for many others as and when duty calls or opportunity knocks.
Recently, along with a like minded friend, I have started to conjure up a nice little portable recording rig to allow us to record whenever and wherever we like, whether it be on lunch breaks at work, at home etc. Essentially freedom to record without the studio constraints is the aim of the game.
Concept - one briefcase-like case (flightcase, pellican case etc, all dependent on what i can acquire) with one IEC socket will be plugged in to provide power to the rig (one laptop and two fire wire interfaces).
Foot controller - Bearing in mind most brass instruments take two hands to wield and we may be recording on our own, I want to add some kind of foot control system to the build, to enable ease of use. Having read about the ability of the ATMega32u4 to appear and function like a HID such as a keyboard my mind set to work; why not use one to send keystrokes to the Laptop with footswitches?
Keyboard shortcuts could be configured using something like AutoHotKeys, allowing full control of the laptop and the recording software's features while being able to concentrate on the task at hand.
***Pro Micro 32u4 ORDERED - AND RECEIVED!***
I'm thinking that it will be quite a simple circuit for the box; all the switches will be wired up to 5v, and the other side of the switches will be wired to pins on my new pro mini and to ground (via 10k Resistors to avoid creating a short).
Unsure of how yet but when the Pro Mini detects a change in state a void for that button will send the keystrokes to the laptop.
Managed to get my little Micro firing some "IT'S ALIVE!!!!!!!" text to an open text document. I don't have any switches purchased for the build yet, so just using a jumper to bridge 5v to my data pin/ground. Some switches would be lovely!
Next step is to add more buttons to my rudimentary code and also increase functions it carries out.
I'm also looking to add a little 16x2 display (using the I2C converter board to save pins), and also a selector switch to allow multiple layers to be assigned to the buttons.
It has been a very long time since I've been able to do anything remotely fun with any of my projects due to work and band commitments over the last month or two. While work has not let up i am hoping to get some more of this project done!
I have purchased 5 momentary footswitches and have been given a 6-position selector switch; if I can these working I'll be able to have 30 commands at my disposal. I have my pro micro breadboarded and 4 'switches' set up, plus have decided to try and incorporate 2 16x2 lcd displays to give me more room to display button functions etc.
In order to save pins with the selector switch i am going to use a series of resistors in conjunction with the selector switch to return different values to one analog pin based on which pin is selected.
Coding work is underway too - I'm looking to use some arrays to map out what void should be triggered based on the current selector position and what button has been pressed.
I am aiming to have my code check what position the selector switch is in and what button has been pressed and then return a function name from an array of strings. Then using some if, else if and else statements fire the intended key commands.
The LCD screens will display the array information for each of the buttons based on the selector switch too.
The use of arrays,, i2c screens and buttons etc is something completely new to me, so it's a long journey to get in functional!
Good news - an enclosure has been found! I found an old portable banner stand that was being thrown out, so i saved it from the skip, took out the innards and essentially cut it in half. I have cut holes for the 5 switches and potentiometer, however I'm contemplating getting a bigger screen to put in the project.
Before and after hacking :-)
The switch holes need a bit more work but i have ran out of time - that will happen Monday.
Code has took a big step forward today too - Now the code checks the values from the pressed button and also the selector switch and returns a string from the Array. It then processes the key commands associated to that string. Wahey!!!!
Now i just need to sort out the resistor series for the the selector switch, as i currently have the code just defaulting to position one for now.
Once that is done i will wire up my switches to my Pro Micro, add the USB port to the enclosure etc and then give it a go!
Then screen work shall commence...
*** UPDATE - 15/08/2014 ***
Here is a pastepin link to my current sketch so far:
As it stands It all works nicely - apart from the for loop checking the button pins.
It will detect button presses, however only sequentially - it's as if it sits and waits for each of the buttons to be pressed before moving to the next button.
My head hurts! Any suggestions would be greatly appreciated (thanks already to lumi and bdk6 for helping!)
More work to follow hopefully!