Show Posts
Pages: [1]
1  Using Arduino / Audio / Re: MIDI Footswitch on: August 15, 2012, 09:15:04 am
PROBLEM SOLVED !  smiley-sweat

Someone sent me a very good program and very simple also, that not only made everything work, it also discards the need for 2 inputs, one is enough!!
I also used a 10K resistor instead of 1K and a 100 ohm resistor before the 5V that go into the switch middle pin.

The code used:
Code:
#define pin2 2
byte vsw1;

void setup()
{
}
void loop()
{ if (vsw1 != digitalRead(pin2))
  { if (vsw1 == 0) {midiSend( 0xB0, 0x5B, 0x00 );
                    vsw1 = 1;
                  delay(1);}
              else {midiSend( 0xB0, 0x5B, 0x7F );
                    vsw1 = 0;
                  delay(1);}
  }
}
void midiSend(char cc, char data1, char data2) {
  Serial.begin(31250);
  Serial.print(cc, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
  Serial.end();
}

Thank you very much to all who helped smiley
2  Using Arduino / Audio / Re: MIDI Footswitch on: August 15, 2012, 05:35:20 am
Update:
I tried turning that internal pullup in the program to LOW, and seems the same. It seems no matter what i do, it always ends up the same.
It's really frustrating  smiley-cry
It keeps randomly failing to read the input i give through the footswitch. The footswitch works fine, i tested with a multimeter.
The serial comunication seems in order too, that's not where it's failing either.

Is there a simple program/circuit i can use to check if the inputs of the arduino are 100% ok?
3  Using Arduino / Audio / Re: MIDI Footswitch on: August 15, 2012, 02:47:52 am
Hi! Thanks for answering  smiley
Hmm, well, i will show you my circuit:



Given this circuit, how would you advise me to change the code?

Regards.
4  Using Arduino / Audio / Re: MIDI Footswitch on: August 14, 2012, 08:46:51 am
Update:
I replaced the 1K resistors with 10K resistors.. same thing..
On the Arduino, i used a voltmeter in AC mode to read the voltage between the 5V pin and GND and it gave 10,2 V AC !!! Is this normal? (in DC mode it reads 5 V)

I'm powering the Arduino with a 9V battery (between Vin and GND)
5  Using Arduino / Audio / Re: MIDI Footswitch on: August 14, 2012, 02:15:43 am
Right, here it is, it's an adaptation of one i saw on the web:

Code:
#define SWITCH1 2
#define SWITCH2 3

#define BOUNCEDELAY 1

int switches[2] = { SWITCH1, SWITCH2 };
int switchState[2] = { HIGH, HIGH };

int currentSwitch = 0;
int currentProgram = 22;   // current program - sent to the output
int bypassState = LOW;     // state of bypass pedal


void setup() {
  //  Set MIDI baud rate:
  Serial.begin(31250);

  // Setup Switches and activation LEDs
  for( currentSwitch = 0; currentSwitch < 2 ; currentSwitch++ ) {
    pinMode( switches[currentSwitch], INPUT );          // Set pin for switch
    digitalWrite( switches[currentSwitch], HIGH );      // Turn on internal pullup
  }
}
void loop() {
  for( currentSwitch = 0; currentSwitch < 2; currentSwitch++ ) {
    if((digitalRead(switches[currentSwitch]) != switchState[currentSwitch] )&&(switchState[currentSwitch] == HIGH)){
      switch( currentSwitch ) {
        case 0:
          //Bypass
          if( bypassState == LOW ) {
            bypassState = HIGH;
            midiSend( 0xB0, 0x5B, 0x00 ); // bypass off
            
          }
          else {
            bypassState = LOW;
            midiSend( 0xB0, 0x5B, 0x7F ); // bypass on
            
          }
          break;
}
      delay( BOUNCEDELAY );
    }
    switchState[currentSwitch] = digitalRead( switches[currentSwitch] );
  }  
}

//  Send a three byte midi message  
void midiSend(char status, char data1, char data2) {
  Serial.print(status, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
}

It might look rather strange using case, and there is an unused variable there. But as i said it's an adaptation.
The problem i'm talking about also happened in various other sketches with different programing. I'm going to try different value resistors anyway...
6  Using Arduino / Audio / MIDI Footswitch on: August 13, 2012, 11:15:27 am
Hi! I'm new to this forum.
I started trying to build a midi footswitch to use with guitar software on the PC.
A Double Throw foostswitch connects to the Arduino, using 2 digital inputs. one switch position goes on input 2 and the other in input 3, the middle connection goes to the 5v of the Arduino. It's all connected with the pushbutton method on the examples of the arduino. i'm using a 1k resistor on each input (to GND).
Then i use Digital port 1 for sending serial data to a 5 pin MIDI connector which connects to a MIDI->USB interface.
The software detects the midi device and uses it to toggle an effect on/off.

It's all working, BUT.. sometimes, the arduino doesn´t detect/send the midi command when i use the footswitch. It's a random thing, every X clicks, it fails.
What could be wrong? (the footswitch is in order, i tested it)

Using Arduino ver 0022
7  Using Arduino / Audio / Re: Problem with sending MIDI CC messages on: August 13, 2012, 10:50:32 am
Hello. Have you tried formatting all the data bytes in the 0x.. as you did for the 0xB0 command?

What about instead of serial.write using serial.print ?

I'm doing a similar program but with digital input only (yet)

Here is my code as far as the serial comm goes:

Code:
void midiSend(char status, char data1, char data2) {
  Serial.print(status, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
}

I'm using Arduino 0022, not 1.0
Regards.
Pages: [1]