Thursday, January 20, 2011

Since my Arduino Mega just shipped today, I only have volume and wah to test really.

The FCB1010 chassis comes with 2 expression pedals that can be used to vary a plethora of things. For me, I just want things to be the way they used to be: wah on the left, volume on the right.

What makes volume and wah unique from the effects discussed previously are three things: 1. They are variable and work via potentiometers instead of pushbuttons, 2. They are analog inputs and not digital and 3. In the software, they are controlled by a Control Change instead of a Program Change(effects).

The hardware setup is as in the image below if you wish to test.

The code for both is the same. I'll admit I grabbed the code from this site. No shame in not re-inventing the wheel.

The control code for volume is 0x07 and the wah control is 0x11. It took some trial and error to find the wah control code since there is a typo in the documentation. “Wah off/position” should be “Wah on/position”.

Here's the code to enable wah. Just change 0x11 to 0x07 for volume.
// Constant
const int POT_PIN = 0;              // Pot connected to analog pin 0
const int POT_THRESHOLD = 7;        // Threshold amount to guard against false values
const int MIDI_CHANNEL = 0;         // MIDI Channel 1

void setup()
{
    Serial.begin(31250);     // Starts communication with the serial port
}

void loop()
{
    static int s_nLastPotValue = 0;
    static int s_nLastMappedValue = 0;

    int nCurrentPotValue = analogRead(POT_PIN);
    if(abs(nCurrentPotValue - s_nLastPotValue) < POT_THRESHOLD)
        return;
    s_nLastPotValue = nCurrentPotValue;

    int nMappedValue = map(nCurrentPotValue, 0, 1023, 0, 127); // Map the value to 0-127
    if(nMappedValue == s_nLastMappedValue)
        return;
    s_nLastMappedValue = nMappedValue;
    if(nMappedValue >= 15){
    
      MidiVolume(MIDI_CHANNEL, nMappedValue);
    }
}

void MidiVolume(byte channel, byte volume)
{
    Serial.print(0xB0 | (channel & 0x0F), BYTE);    // Control change command
    Serial.print(0x11, BYTE);                       // Volume command
    Serial.print(volume & 0x7F, BYTE);              // Volume 0-127
}


Still to Come


Beyond the breadboard: PCB and wiring
10 effect bank: 2 footswitch boards
Awesome eye candy: LCD screen
<- Part 2       Part 4 ->
Reactions:
Categories: , , , ,

2 comments:

  1. What value of pot are you using? Does it give a full range? How many turns?

    ReplyDelete
  2. It's been a while since I did this. I was actually using the optical rheostats that come with the FCB1010. I think they have a value of 0-10K Ohms.

    ReplyDelete

Subscribe to RSS Feed Follow me on Twitter!