Thanks UKHeliBob, I completely missed that space in the array.
I'm still not grasping what PaulS advised on and trying to find some examples.
/*
Keyboard Message test
For the Arduino Leonardo and Micro.
Sends a text string when a button is pressed.
The circuit:
pushbutton attached from pin 4 to +5V
10-kilohm resistor attached from pin 4 to ground
created 24 Oct 2011
modified 27 Mar 2012
by Tom Igoe
modified 11 Nov 2013
by Scott Fitzgerald
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/KeyboardMessage
*/
#include <MIDI_controller.h> // include the library
#include "Keyboard.h"
int buttonPins[9] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
int previousButtonState[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW}; // for checking the state of a pushButton
const static byte Channel_Volume = 0x07; // controller number 7 is defined as Channel Volume in the MIDI implementation.
const static byte Pan_Volume = 0x0A;
const static size_t analogAverage = 8; // Use the average of 8 samples to get smooth transitions and prevent noise
Analog fader1(A0, Channel_Volume, 1); // Create a new instance of the class 'Analog, called 'fader', on pin A0, that sends MIDI messages with controller 7 (channel volume) on channel 1.
Analog fader2(A1, Pan_Volume, 1);
char keyValues[] = " ?,.rms??";
void setup()
{
for (int i = 0; i < 9; i++)
pinMode(buttonPins[i], INPUT_PULLUP);
Keyboard.begin(); // initialize control over the keyboard:
{
USBMidiController.blink(13); // flash the LED on pin 13 on every message
USBMidiController.setDelay(15); // wait 15 ms after each message not to flood the connection
delay(1000); // Wait a second...
fader1.average(analogAverage); // Use the average of 8 samples to get smooth transitions and prevent noise
fader2.average(analogAverage);
}
keyValues[1] = (char)KEY_RETURN;
keyValues[7] = (char)KEY_UP_ARROW;
keyValues[8] = (char)KEY_DOWN_ARROW;
}
void loop()
{
fader1.refresh(); // refresh the fader (check whether the input has changed since last time, if so, send it over MIDI)
fader2.refresh();
{
for (int i = 0; i < 9; i++)
{
int buttonState = digitalRead(buttonPins[i]); // read the pushbutton
if ((buttonState != previousButtonState[i]) // if the button state has changed
&& (buttonState == LOW)) // and it's currently pressed
{
byte arrLen = strlen(keyValues);
for (byte b = 0; b = arrLen; b++);
{
Keyboard.write(keyValues[i]);
}
}
previousButtonState[i] = buttonState; // save the current button state for comparison next time
}
}
}
Dizzwold.