// Axe-FX midi.controller 05-Oct-2016
// V4.4
#include <MIDI.h> //Midi library Version 3.2
#include <LiquidCrystal.h>
#define SWITCH1 22
#define SWITCH2 24
#define SWITCH3 26
#define SWITCH4 28
#define SWITCH5 30
#define SWITCH6 32
#define SWITCH7 34
#define SWITCH8 36
#define SWITCH9 38
#define SWITCH10 40
#define SWITCH11 42
#define SWITCH12 44
#define SWITCH13 46
#define SWITCH14 48
#define SWITCH15 50
#define SWITCH16 52
#define SWITCH17 14
#define SWITCH18 15
#define SWITCH19 16
#define SWITCH20 17
#define LED1 23
#define LED2 25
#define LED3 27
#define LED4 29
#define LED5 31
#define LED6 33
#define LED7 35
#define LED8 37
#define LED9 39
#define LED10 41
#define LED11 43
#define LED12 45
#define LED13 47
#define LED14 49
#define LED15 51
#define LED16 53
#define LED17 18
#define LED18 19
#define LED19 20
#define LED20 21
#define MIDICHAN 1 //MIDI channel
#define FX1CC 23 //CC channel for FX1
#define FX2CC 25 //CC channel for FX2 (Ext 8 on Axe)
#define FX2ndCC 16 //CC for 2nd git's FX
#define VOLPEDCC 11 //CC to control overall Axe volume
#define TUNERCC 15 //CC to engage tuner
#define CLEAN1stCC 100 //CC for 1st git's clean channel
#define CLEAN2ndCC 101 //CC for 2nd git's clean channel
#define EXP0CC 22 //CC for expression pedal 0
#define EXP1CC 24
#define EXP2CC 18 //Ext 4
#define SceneCC 34 //CC for scene
#define LoopRecordCC 28
#define LoopPlayCC 29
#define LoopOnceCC 30
#define LoopDubCC 31
#define LoopRevCC 32
#define LoopBypassCC 33
#define LoopHalfCC 120
#define LoopUndoCC 121
#define BOUNCEDELAY 25
/* LCD definition
* LCD RS pin to digital pin 8
* LCD Enable pin to digital pin 9
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
* LCD BL pin to digital pin 10
* KEY pin to analogl pin 0
*/
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
// Variables:
int switches[20] = { SWITCH1, SWITCH2, SWITCH3, SWITCH4, SWITCH5, SWITCH6, SWITCH7, SWITCH8,
SWITCH9, SWITCH10, SWITCH11, SWITCH12, SWITCH13, SWITCH14, SWITCH15, SWITCH16,SWITCH17, SWITCH18, SWITCH19, SWITCH20};
int switchState[20] = { HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH , HIGH , HIGH , HIGH };
// Initial state of switch is high due to internal pullup
int Toggle[20] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1 , 1 , 1};
int leds[20] = { LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8, LED9, LED10, LED11, LED12, LED13, LED14, LED15, LED16, LED17, LED18, LED19, LED20 };
int currentSwitch = 0;
int pedalActiveFlash = 50; // Delay for flash when pedal is pressed
int PresetNumb = 0; //Initial preset number for preset selection
void setup() {
// LCD Initial Message
lcd.clear();
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("AxeFX Controller");
// Set MIDI baud rate:
Serial.begin(31250);
//Serial.begin(9600);
// Setup Switches and activate LEDs
for( currentSwitch = 0; currentSwitch < 20; currentSwitch++ ) {
pinMode( switches[currentSwitch], INPUT_PULLUP); // Set pin for switch
digitalWrite( switches[currentSwitch], HIGH ); // Turn on internal pullup
pinMode( leds[currentSwitch], OUTPUT ); // Set pin for LED
flashPin( leds[currentSwitch], 100 ); // Flash LED
}
}
void loop() {
for( currentSwitch = 0; currentSwitch < 20; currentSwitch++ ) {
if((digitalRead(switches[currentSwitch]) != switchState[currentSwitch] )&&(switchState[currentSwitch] == HIGH)){
switch( currentSwitch ) {
// Switch 1. Select preset on switch 1
case 0:
midiProg(0xC0, PresetNumb);
digitalWrite( LED1, HIGH);
digitalWrite( LED2, LOW);
digitalWrite( LED3, LOW);
digitalWrite( LED4, LOW);
digitalWrite( LED5, LOW);
lcd.clear(); lcd.begin(16, 2); lcd.setCursor(0,0); lcd.print(PresetNumb); lcd.print("-");lcd.print(PresetNumb+4);
lcd.setCursor(7,0); lcd.print("Preset "); lcd.print(PresetNumb);
break;
// Switch 2. Select preset on switch 2
case 1:
midiProg(0xC0, PresetNumb+1);
digitalWrite( LED1, LOW);
digitalWrite( LED2, HIGH);
digitalWrite( LED3, LOW);
digitalWrite( LED4, LOW);
digitalWrite( LED5, LOW);
lcd.clear(); lcd.begin(16, 2); lcd.setCursor(0,0); lcd.print(PresetNumb); lcd.print("-");lcd.print(PresetNumb+4);
lcd.setCursor(7,0); lcd.print("Preset "); lcd.print(PresetNumb+1);
break;