I’ve put together a short video showing the Bass Pedal project in its current state. Enjoy.
The next step will be to add voice control, so that I can shift it form the default piano voice and perhaps an LCD display panel showing the currently selected options. This could display the current octave, transpose setting, voice and volume.
Great stuff! Nicely edited video too. 🙂
Hi,
Is this project still active?
I have sucessfully used your details to build my own midi bass pedals.
I have resolved some small bugs I found in the diagrams and code and added program change and portamento on/off
If this is still an active project I can upload my findings.
Regards,
Doug
Hi Doug,
Thanks for your comment, I’m still planning to come back to this project when time permits. I’ve completed a circuit board design that needs testing and I’m planning on adding a better display than just the LEDs. I’d be very interested to see the corrections/improvements you have made and of course pictures of your finished project.
Rob
Hi,
Sorry not that familiar with your website.
Here’s my code. Complete with the changes I made.
I found that the code on the web site had html changes for and &
There were also some segments that had been obscured by comments.
==================================================
// MultiButtonMIDI.ino
// Driving MIDI using a Multiple Buttons
// Rob Ives 2012
// Modified by D.Irvine 09-2013
// This code is released into the Public Domain.
#include
#include
#define LED 13 // LED pin on Arduino board
int keyispressed[16]; //Is the key currently pressed?
int noteisplaying[16]; //Is the Note currently playing?
int portnoteisplaying = 0; //Is the portamento Note currently playing?
unsigned char data1; //data from chip 1
unsigned char data2; //data from chip 2
int transpose = 0; //transpose notes on the board
int octave = 2; //set currently played octave
int patch = 40; //set currently patch
int velocity = 127; //set note velocity
//— Octave LED output pins
int octave1 = 8;
int octave3 = 9;
//— Octave Switches
int octaveup = 7;
int octavedown = 6;
//— Patch Switches
int patchup = 5;
int patchdown = 4;
//— Portamento Switches
int porton = 3;
//— Pot
int potpin = 2;
void setup() //The Setup Loop
{
Wire.begin(); // setup the I2C bus
for (unsigned int i = 0; i < 16; i++) { //Init variables
keyispressed[i] = 1; //clear the keys array (High is off)
noteisplaying[i] = 0; //no notes are playing
portnoteisplaying = 0; //no notes are playing for portamento section
}
//— Set up pins
pinMode(LED, OUTPUT); //Set pin 13 , the led, to output
pinMode(octaveup, INPUT);
pinMode(octavedown, INPUT);
pinMode(octave1, OUTPUT);
pinMode(patchup, INPUT);
pinMode(octave3, OUTPUT);
pinMode(patchdown, INPUT);
pinMode(porton, INPUT);
MIDI.begin(); //initialise midi library
displayoctave(); //display the current octave
}
//———————————————
void loop() //the main loop
{
readkeys();
sendMIDI();
checkoctave();
patchstate();
portamento();
}
//————————————-
void readkeys() { //Read the state of the I2C chips. 1 is open, 0 is closed.
Wire.requestFrom(0x38, 1); // read the data from chip 1 in data1
if (Wire.available()){
data1 = Wire.read();
}
Wire.requestFrom(0x39, 1); // read the data freom chip 2 into data2
if (Wire.available()){
data2 = Wire.read();
}
for (unsigned char i = 0; i > i) & 1); // set the key variable to the current state. chip 1
keyispressed[i + 8] = ((data2 >> i) & 1); //chip 2
}
}
//————————————-
void sendMIDI() { // Send MIDI instructions via the MIDI out
int note; //holder for the value of note being played
velocity = analogRead(potpin)/8;// Read velocity from the pot
for (unsigned char i = 0; i < 16; i++) { //for each note in the array
if (keyispressed[i] == LOW){ //the key on the board is pressed
if(!noteisplaying[i]){ //if the note is not already playing send MIDI instruction to start the note
note = i + (octave*12);
MIDI.sendNoteOn(note,velocity,1); // Send a Note ( vel.127 ch. 1)
digitalWrite(LED,HIGH); // turn on the LED
noteisplaying[i] = 1; // set the note playing flag to TRUE
}
}
else{
if(noteisplaying[i]){ //if the note is currently playing, turn it off
note = i + (octave*12);
MIDI.sendNoteOff(note,0,1); // Stop the note
digitalWrite(LED,LOW); //turn off the LED
noteisplaying[i] = 0; // clear the note is playing flag
}
}
}
}
//—————————————-
void checkoctave(){
int up = digitalRead(octaveup);
int down = digitalRead(octavedown);
if(up == LOW){//up button pressed
if(octave 1){
octave–;
}
while(down == LOW){// wait until button is released
down = digitalRead(octavedown);
delay(20);
}
displayoctave();
}
}
//—————————————-
void patchstate(){
int up = digitalRead(patchup);
int down = digitalRead(patchdown);
if(up == LOW){//up button pressed
if(patch 1){
patch–;
}
while(down == LOW){// wait until button is released
down = digitalRead(patchdown);
delay(20);
}
sendpatch();
}
}
//—————————————-
void portamento(){
int portamentoin = digitalRead(porton);
if (portamentoin == LOW){ //the key on the board is pressed
if(!portnoteisplaying){ //if the note is not already playing send MIDI instruction to start
MIDI.sendControlChange(5,55,5); // Send portamento on 0xB0 Continuous controller – cc5 turns portamento rate
MIDI.sendControlChange(65,127,5); // Send portamento on 0xB0 Continuous controller – cc65 turns portamento on/off
// digitalWrite(LED,HIGH); // turn on the LED
portnoteisplaying = 1; // set the note playing flag to TRUE
}
}
else{
if(portnoteisplaying){ //if the note is currently playing, turn it off
MIDI.sendControlChange(65,0,5); // Stop the note
// digitalWrite(LED,LOW); //turn off the LED
portnoteisplaying = 0; // clear the note is playing flag
}
}
}
//————————————-
void displayoctave(){
// clear all the LEDs
digitalWrite(octave1, HIGH);
digitalWrite(octave3, HIGH);
// …and then display the current octave
switch(octave){ // display the current octave
case 1: digitalWrite(octave1, LOW);
break;
//case 2: digitalWrite(octave2, LOW);
break;
case 3: digitalWrite(octave3, LOW);
break;
//case 4: digitalWrite(octave4, LOW);
break;
}
}
//————————————-
void sendpatch(){
// send patch
MIDI.sendProgramChange(patch,1); // Send program change – (byte ProgramNumber, byte Channel)
}
===========================================
I’ll try and get Fritzing working and do my hardware changes. Basically adding patch up/down and portamento on/off. I have pictures of the finished pedals but I’m not sure how to post them.
Regards,
Doug
Hi,
Looks like the posting removes the includes for midi and wire – strange.
Regards,
Doug