Another guy With Problems building a MIDI Foot Controller!

Hello Everyone!
Well, my first statement is that I am NOT a programmer, so I am sure you will see me doing many dumb questions, please, be patient!
Second: I've been searching the internet for 4 whole days, but without Success... My issue seems really simple solving, but I think that I am not smart enough to solve that alone haha

Here we go:
I am a guitar player, and I am trying to build a Foot controller using Arduino.
My issue is: I simply CAN't neither find a working code nor modify an existing one so It can work properly.
I need the analog input's (only 2 of them for now) to work with potentiometers, so I can control Wah Wah/Expression/Whammy and so on.
And I need the digital pins to work as On/Off switches (more like a toggle), But I CAN'T make anything work on the digital pins.

In one Hand, I do have a partially working code, which let's me Chose WHICH MIDI CC I want to trigger (this is really important!), but does NOT let me chose which INPUT I want it to be, For Example:
I want MIDI CC 40 in Analog Pin 7.
For that, I'd have to do this in this code: (See "working.txt" attachmet!)


This would be "OK", But I'd have to ground all other unused PIN's.
This is an example only, so I would really be OK using only Analog ports 0 and 1. But would be better if I could point which port I want to use.
Here's an image of what happens when I upload this code to the arduino:

(This is an older version of the code, where I used only 1 analog input, to trigger the MIDI CC 22)


On the other hand, I have a code which let's me point to WHICH port I wish to use, BUT, doesn't let me point WHICH MIDI CC I want to use, and this is unfortunately, not good.
There's a plus: Once I upload this code to the arduino, it only generates RAMDOM MIDI CC's, and that's even more annoying.
Here's the code: (See "Not working.txt" attachmet!)

And here's an image of it triggering random MIDI messages:

Gustavo Silveira, who is the one who developed this code, was talking to me over facebook and trying to help me, but for some reason, the code really won't work properly with me.


So, if one of you who really understands of programming could help me, I'd really be happy!
Would be good to help me realize how to modify the "Working" one, and make it usable with the digital pins for On/Off commands, and also, to point which analog port I want to use!

I REALLY searched the entire internet.
I came along several "solutions", but neither of them worked for me, and it made me really upset, since I am since Monday searching and searching, with no lucky...
I tried to use the "switch" library, no success.
I tried to understand how digital pins work and from that, start building the code , also with no success..
I hope I provided all the needed Info!
Thanks in advance!

Not Working.txt (4.86 KB)

Working.txt (1.16 KB)

I don't have a clue why the images are not showing, but here they are:

Imgur
Imgur

Somebody help please!

How are your digital inputs wired ?
Do you have any pullup resistors holding them HIGH when the buttons are not pressed or are they floating at an uncertain voltage ?

Take a look at my Arduino MIDI Controller library. Sounds like it does everything you need (and more).

Pieter

Hey Guys!
Thanks for answering. In the meantime I managed to make it work. It was hard, but I could make it!
Anyways, thanks for replying!