Show Posts
Pages: [1] 2
1  Using Arduino / Networking, Protocols, and Devices / Re: ardOSC and WIFI library help on: December 11, 2012, 02:55:40 pm
Has anyone had a chance to look at the updated ArdOsc library made for the wifly module? https://github.com/Zapalot/ArdOscForWiFlyHQ unfortunately I have the arduino wifi module, not the wifly, but am planning to take a look and see if I can get it to communicate with my arduino...
2  Using Arduino / Motors, Mechanics, and Power / Interfacing Arduino with Pololu JRK21v3 help please! on: March 07, 2012, 04:44:03 pm
hello!

I'm trying to interface my arduino due with the jrk21v3 using the following code (software serial):

Code:
#include <SoftwareSerial.h>


SoftwareSerial mySerial(2,3); // 2 - tx, 3 - rx

int target = 2500;  // this is the target speed  that I want for the jrk motor controller.

byte serialBytes[2]; // declare an array for the speed command

void setup()
{

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);


}
void loop()
{


  serialBytes[0] =  0xC0 + ( target & 0x1F); // Command byte holds the lower 5 bits of target. 
  serialBytes[1] =  (target >> 5) & 0x7F;   // Data byte holds the upper 7 bits of target. 

  //0xAA, device number, 0x40 + target low 5 bits, target high 7 bits


  //Send a Pololu Protocol command
  mySerial.write(0xAA);     //start byte
  mySerial.write(0x0B);     //device id
  mySerial.write(0x40);     //command number
  mySerial.write(serialBytes[0]); //speed
  mySerial.write(serialBytes[1]); //speed



}

which is similar to the code from this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1283904250

and my jrk is configured to:
serial input, UART detect baud rate, device number 11,no CRC, with analog feedback.

when i use to USB to my computer, i can control the motor no problem, but then i connect the arduino to the JRK, the jrk does not respond to the arduinos serial command

could anyone help out? (unfortunately this is for a school project smiley-sad )

Thanks!
3  Using Arduino / Programming Questions / Re: Midi sys Ex program working on duem, but not oh mega, help please! on: July 31, 2011, 08:24:24 pm
but how would that make a difference? i have the lcd working on both without issue on those pins...

Thanks!
4  Using Arduino / Programming Questions / Midi sys Ex program working on duem, but not oh mega, help please! on: July 31, 2011, 12:34:32 pm
Hello there, I am working on an interfacing project for a control board, and used a duemilanove chip to beta test my separate functions and and everthing on it worked, but when i uploaded the project to the mega 2560 board, the same functions did not work.

for the duemilanove, i used the midi shield, and a serial 16x2 lcd module, my application requires bi-directional midi communication thus i jumped the midi read pins 5,4 to midi outpins 3,1 , respectively (as per manufacturer's design).

I uploaded the following program to the duemilanove, and it worked perfectly:

Code:
#include <MIDI.h>
#include <LiquidCrystal.h>
// LCD Pins (4, 5,10,11,12,13)
LiquidCrystal lcd(6, 5, 10, 11, 12, 13);

char * Notes[12] = {
  "A ","Bb","B ","C ","Db","D ","Eb","E ","F ","Gb","G ","Ab"};
byte index1[8] = {
  B11111,B01110,B00100,B00000,B00100,B01110,B11111}; //custom index character
byte index2[8] = {
  B00000,B00100,B01110,B11111,B01110,B00100,B00000}; //custom index character
int SwitchState = HIGH;
int SwitchState2 = HIGH;
byte RQSTNAME[5] = {
  0x00,0x01,0x74,0x01,0x0f};
byte *RFN = RQSTNAME;

void setup(){
  lcd.createChar(0,index1);
  lcd.createChar(1,index2);
  lcd.begin(16,2);
  pinMode(2,INPUT); //tuner button
  digitalWrite(2,HIGH);
  pinMode(3,INPUT); //present name request button
  digitalWrite(3,HIGH);
  MIDI.begin();
}

void loop(){
  int sizear;
  if(digitalRead(2) == LOW && SwitchState ==HIGH){ //if tuner button is pressed
    MIDI.send(ControlChange, 15,127,1);
    delay(250);
    Tune();
    lcd.clear();
  }
  digitalWrite(2,HIGH);
  /*
MIDI.read();          //read the midi
    MIDI.getSysExArray();
    sizear = MIDI.getData1();
   
    if((MIDI.getSysExArray())[5] ==0x0d && sizear ==10){ //if tuner message is recieved
    Tune();
   
    }
   */

  if(digitalRead(3) ==LOW &&SwitchState2 ==HIGH){
    ReName();

  }


}

void Tune(){

  int note;
  int tune;
  int tunepos;
  int oct;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Note: ");
  while (digitalRead(2) != LOW && SwitchState == HIGH){
    MIDI.read();
    int index = 0;
    note = MIDI.getSysExArray()[6];
    oct = MIDI.getSysExArray()[7];
    tune = MIDI.getSysExArray()[8];
    lcd.setCursor(7,0);
    lcd.print(Notes[note]);
    lcd.setCursor(0,1);
    lcd.print("                "); //clear bottom row

    if(0 <=tune && tune<15){
      tunepos=1;
    }
    if(15<=tune && tune<30){
      tunepos=2;
    }
    if(30<=tune&& tune <45){
      tunepos=3;
    }
    if(45<=tune&& tune<55){
      tunepos=4;
    }
    if(55<=tune&& tune<60){
      tunepos=5;
    }
    if(60<=tune&& tune<63){
      tunepos=6;
    }
    if(63<=tune&& tune<65){
      tunepos=7;
      index = 1;
    }
    if(65<=tune&& tune<68){
      tunepos=8;
    }
    if(68<=tune&& tune<73){
      tunepos=9;
    }
    if(73<=tune&& tune<83){
      tunepos=10;
    }
    if(83<=tune&& tune<98){
      tunepos=11;
    }
    if(98<=tune&& tune<113){
      tunepos=12;
    }
    if(113<=tune&& tune<128){
      tunepos=13;
    }
    lcd.setCursor(tunepos,1);
    lcd.write(index); //prints custom index charater
    delay(15);
  }
  digitalWrite(2,HIGH);
  MIDI.send(ControlChange, 15,0,1);
  delay(250);
  lcd.clear();

}

void ReName(){
  int sizear;
  int nmbrchar;
  byte chars;
  MIDI.sendSysEx(5,RFN); //length is either 5 or 7 with sysex markers
  MIDI.read();
  MIDI.getSysExArray(); //need to make sure arduino recieves the sysex msg for present name in time, may need a delay or waiting loop...
  sizear = MIDI.getData1();
  if((MIDI.getSysExArray())[5] ==0x0f && sizear>10){
    lcd.clear();
    lcd.setCursor(0,0);
    for(int i=6;i<(sizear-8);i++){ //option 1
   
      chars = (MIDI.getSysExArray())[i];
      if(MIDI.getSysExArray()[i] !=0x00){
      lcd.print(chars); }
    }


  }
}



then, i made a MIDI interface using TOM SCRAFFS MIDI LAYOUT with a 6N139 chip, with everything hooked up properly as it seems, and using 1k for R3 & R2. I checked my midi out works, and even the midi in works (the program can read program change and control change messages), but for some reason the SysExArray does not seem to working when i use this code, where the button pins are changed and working, but the actual SysEx doesnt seem to be working.

Code:
#include <MIDI.h>
#include <LiquidCrystal.h>
// LCD Pins (4, 5,10,11,12,13)
LiquidCrystal lcd(7,6,3,2,5,4);

char * Notes[12] = {
  "A ","Bb","B ","C ","Db","D ","Eb","E ","F ","Gb","G ","Ab"};
byte index1[8] = {
  B11111,B01110,B00100,B00000,B00100,B01110,B11111}; //custom index character
byte index2[8] = {
  B00000,B00100,B01110,B11111,B01110,B00100,B00000}; //custom index character
int SwitchState = HIGH;
int SwitchState2 = HIGH;
byte RQSTNAME[5] = {
  0x00,0x01,0x74,0x01,0x0f};
byte *RFN = RQSTNAME;

void setup(){
  lcd.createChar(0,index1);
  lcd.createChar(1,index2);
  lcd.begin(20,2);
  pinMode(52,INPUT); //tuner button
  digitalWrite(52,HIGH);
  pinMode(53,INPUT); //present name request button
  digitalWrite(53,HIGH);
  MIDI.begin();
}

void loop(){
  int sizear;
  if(digitalRead(52) == LOW && SwitchState ==HIGH){ //if tuner button is pressed
    MIDI.send(ControlChange, 15,127,1);
    delay(250);
    Tune();
    lcd.clear();
  }
  digitalWrite(2,HIGH);
  /*
MIDI.read();          //read the midi
    MIDI.getSysExArray();
    sizear = MIDI.getData1();
   
    if((MIDI.getSysExArray())[5] ==0x0d && sizear ==10){ //if tuner message is recieved
    Tune();
   
    }
   */

  if(digitalRead(53) ==LOW &&SwitchState2 ==HIGH){
    ReName();

  }


}

void Tune(){

  int note;
  int tune;
  int tunepos;
  int oct;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Note: ");
  while (digitalRead(52) != LOW && SwitchState == HIGH){
    MIDI.read();
    int index = 0;
    note = MIDI.getSysExArray()[6];
    oct = MIDI.getSysExArray()[7];
    tune = MIDI.getSysExArray()[8];
    lcd.setCursor(7,0);
    lcd.print(Notes[note]);
    lcd.setCursor(0,1);
    lcd.print("                "); //clear bottom row

    if(0 <=tune && tune<15){
      tunepos=1;
    }
    if(15<=tune && tune<30){
      tunepos=2;
    }
    if(30<=tune&& tune <45){
      tunepos=3;
    }
    if(45<=tune&& tune<55){
      tunepos=4;
    }
    if(55<=tune&& tune<60){
      tunepos=5;
    }
    if(60<=tune&& tune<63){
      tunepos=6;
    }
    if(63<=tune&& tune<65){
      tunepos=7;
      index = 1;
    }
    if(65<=tune&& tune<68){
      tunepos=8;
    }
    if(68<=tune&& tune<73){
      tunepos=9;
    }
    if(73<=tune&& tune<83){
      tunepos=10;
    }
    if(83<=tune&& tune<98){
      tunepos=11;
    }
    if(98<=tune&& tune<113){
      tunepos=12;
    }
    if(113<=tune&& tune<128){
      tunepos=13;
    }
    lcd.setCursor(tunepos,1);
    lcd.write(index); //prints custom index charater
    delay(15);
  }
  digitalWrite(52,HIGH);
  MIDI.send(ControlChange, 15,0,1);
  delay(250);
  lcd.clear();

}

void Tune2(){
  int tune;
  int tuneold;
  while(digitalRead(52) != LOW && SwitchState == HIGH){
  if(MIDI.getSysExArray()[5] > 0){
    tune = MIDI.getSysExArray()[8];
    lcd.clear();
    lcd.print("MIDI IN ");
    lcd.print(MIDI.getSysExArray()[5]);
    if(tune != tuneold){
    lcd.print(tune);
    }
  }
  tuneold=tune;
  }
  digitalWrite(52,HIGH);
   MIDI.send(ControlChange, 15,0,1);
  delay(250);
  lcd.clear();

}

void ReName(){
  int sizear;
  int nmbrchar;
  byte chars;
  MIDI.sendSysEx(5,RFN); //length is either 5 or 7 with sysex markers
  MIDI.read();
  MIDI.getSysExArray(); //need to make sure arduino recieves the sysex msg for present name in time, may need a delay or waiting loop...
  sizear = MIDI.getData1();
  if((MIDI.getSysExArray())[5] ==0x0f && sizear>10){
    lcd.clear();
    lcd.setCursor(0,0);
    for(int i=6;i<(sizear-8);i++){ //option 1
   
      chars = (MIDI.getSysExArray())[i];
      if(MIDI.getSysExArray()[i] !=0x00){
      lcd.print(chars); }
    }


  }
}




I am using Arduino-0021 and Midi library 3.1 for both projects.

any ideas????

Thanks!

This is tom scarffs layout:


5  Using Arduino / Installation & Troubleshooting / Mega 2560 timeout() error on OSx10.6.8 AND W7! on: July 27, 2011, 09:54:11 am
Hey guys, i've creeped the forum and saw this is an open issue with no one solution but heres my take on whats happened up till now:

In december '10 I got the 2560 mega and was able to get it to work perfectly with 0020 OR 0021 (don't remember which) but it was functioning well with W7.

Yesterday, I tried to upload a sketch with OSx10.6.8 with 0022 and I kept on getting the
Code:
avrdude: stk500_2_ReceiveMessage(): timeout
error and the program did not stop the upload.

It would keep on displaying this message may times until it would eventually upload a single sketch randomly (no sequence of plugging in/out and restarting the arduino program gave consistent upload success). Sometimes i'd notice LED 13 (pin 13) would flash as usual before upload, TX and RX begin flashing for a quick moment, then die off before a full load sequence. Then either all LEDs are off, or LED13 would blink at odd intervals.

The same unsuccessful results follow with windows 7 attempt.

On the other hand, the 0022 version uploaded sketches without problem to the duemillanova chip.

Any idea as to why this problem is persistent? (i will try later to downgrade to version 0020 and 0021 and see if there is any success).

Thanks!
6  Using Arduino / Programming Questions / Re: Reading series of MIDI SysEx messages Help Please! on: July 20, 2011, 02:10:43 pm
I think this is a better code... (i've refreshed my memory of pointers smiley-wink)

Code:
#include <MIDI.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 2, 3, 4, 5);

void setup(){
MIDI.begin();
}


void loop(){

int note=0;
int tune=0;
MIDI.read();          //read the midi
        MIDI.getSysExArray();  //store the sysex message as an array (this is array pointer)
        int sizear = MIDI.getData1();
delay(100);
        /*
byte SysExA[sizear];
lcd.clear();
        for(int i=0;i<sizear;i++){    //MUST GET SIZE OF ARRAY FIRST!
SysExA[i] = (MIDI.getSysExArray())[i]; //not necessary
        }*/
       
        byte * SysExA = MIDI.getSysExArray(); //just make another pointer instead of array
        tune = SysExA[6];
       
//MIDI.getSysExArray is acually a pointer, need to use '*' qualifier to see whats inside...



}

7  Using Arduino / Programming Questions / Re: Reading series of MIDI SysEx messages Help Please! on: July 20, 2011, 12:24:26 pm
this is the smaller program i plan on running just with midi in and LCD using midi shield and midi library v2.9 i believe... (code is missing set ups but the idea is there i think)


Code:


#include <MIDI.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 2, 3, 4, 5);

void setup(){
MIDI.begin();
}


void loop(){
byte* SysExA;
int note=0;
int tune=0;
MIDI.read();
delay(100);
lcd.clear(); // should clear and reset lcd ever iteration
SysExA = MIDI.getSysExArray();
        note = SysExA(6);
        tune = SysExA(8);


}

but my issue is that MIDI.getSysExArray is byte* type, but i want to get an array out of it and nothing i do compatible...
8  Using Arduino / Programming Questions / Reading series of MIDI SysEx messages Help Please! on: July 20, 2011, 11:50:32 am
Hello there!

I've been somewhat challenged to integrate reading a set of midi sysex messages into my program, but unfortunately my midi.read skill are not good as my midi.send skills.
The problem:
I have a piece of hardware (AXEFX) which when in tuner mode sends out the following batches of Midi messages:

0xF0 sysex start
0x00 Manf. ID byte0
0x00 Manf. ID byte1
0x7d Manf. ID byte2 (this value is configurable within the Axe-Fx)
0xdd Model #
0x0d Calling Function ID
0x?? Note value (0 = A, 1 = A#, 2 = B, 3 = C etc)
0x?? Note octave
0x?? Fine tune (0 = very flat, 0x7f - very sharp, 0x3f/0x40? - in tune)
0xF7 sysex end


In my current program, i have an external program which is called when the tuner function is enabled, and i want to be able to read these 10 sysex messages and analyze them as they are sent..
The point in the loop is to read the 10 messages, temporarily store them, so if 0xf0 , store the next 8 messages until 0xf7, then set message #6 as note and message #9 as tune.

would anyone be able to help me out with this?

I plan on prototyping this out with just a midi in reader + LCD screen...

Thanks!
9  Forum 2005-2010 (read only) / Troubleshooting / Re: Problem with buttons.. please help on: December 08, 2010, 03:03:06 pm
well that code i'm using the banks as designations for the momentary switches, so i was supposed to digitalWrite the Bank_up and Bank_down as HIGH but i was only doing so for the Bank down button, so in the actual reading of the buttons the up would only work every other time, but i got it sorted out, will have to cut the fat out of the program after i get it to do everything i want, but thank you! smiley-wink
10  Forum 2005-2010 (read only) / Troubleshooting / Re: Problem with buttons.. please help on: December 08, 2010, 02:54:32 pm
Ok got it to work, there was a problem with digitalWrite HIGH to the reading pins
11  Forum 2005-2010 (read only) / Troubleshooting / Re: Problem with buttons.. please help on: December 08, 2010, 12:35:51 pm
heres the whole thing....
Code:
/*
Arduino Mega MIDI foot controller:
-LCD printout
-4 pedals
-13 Instant Access Programmable buttons
- 2 bank up down buttons

R1.2.0 as of Dec.8th 2010:
there is TX contant output...
after one read through the program, it get's stuck on midi send of the pedal..
R1.2.1 12-8-2010
fixed bank down button, still problem with midi send and bank up, resent works nicely

*/
#define S1 51
#define S2 47
#define S3 43
#define S4 39
#define S5 35
#define S6 34
#define S7 30
#define S8 26
#define S9 31
#define Bank_up 27
#define S10 3
#define S11 46
#define S12 50
#define S13 42
#define Bank_down 38
#define Pot_a A0
#define Pot_b A1
#define Pot_c A2
#define Pot_d A3
#define LED1 49
#define LED2 45
#define LED3 41
#define LED4 37
#define LED5 33
#define LED6 32
#define LED7 28
#define LED8 24
#define LED9 29
#define LED10 2
#define LED11 44
#define LED12 48
#define LED13 40

#include <MIDI.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(11, 10, 4, 5, 6, 7);

int SWITCHES[14] = {
  0,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13};
int SWITCHSTATES[14] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int SWITCHVAR[14] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int SWITCHVAR_OLD[14] = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int BANKS[3]={
  0,Bank_up,Bank_down};
int BANKSTATE[3]={
    0,0,0};              
int LEDS[14] = {
  0, LED1,LED2,LED3,LED4,LED5,LED6,LED7,LED8,LED9,LED10,LED11,LED12,LED13};
int LEDSTATE[14] = {
  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
int PEDALS[5] = {
  0,A0,A1,A2,A3};
int PEDALSTATE[5] = {
  0,0,0,0,0};
int PEDALSTATE_OLD[5] = {
  0,0,0,0,0};

void setup() {
  for(int d=1;d<14;d++){
    pinMode(LEDS[d],OUTPUT);
    pinMode(SWITCHES[d], INPUT);
    digitalWrite(SWITCHES[d], HIGH);
    SWITCHSTATES[d] = HIGH;
  }
  for(int d=1;d<3;d++){
    pinMode(BANKS[d], INPUT);
    digitalWrite(BANKS[d], HIGH);
    BANKSTATE[d] = HIGH;
  }
pinMode(36, OUTPUT);
pinMode(25, OUTPUT);

  MIDI.begin();
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Arduino GCP");
  lcd.setCursor(0,1);
  lcd.print("By EN R.1.2.0");
}

int Bank = 0;
int Bank_old = 0;

void loop() { //MAIN LOOP
/*
for(int a=1;a<3;a++){
  if(digitalRead(BANKS[a]==LOW) && (BANKSTATE[a] ==HIGH)){
    delay(75);
    if(BANKS[a] == Bank_up){
      if (Bank ==127) {Bank = 0;}
      else {Bank ++;}
    }
     else if(BANKS[a] == Bank_down){
      if (Bank ==0) {Bank = 127;}
      else {Bank--;};
    }
    else {break;}
  }
  digitalWrite(BANKS[a], HIGH);
}
*/

  if((digitalRead(Bank_down)==LOW) &&(BANKSTATE[2]==HIGH)){// bank down works
    digitalWrite(36,HIGH);
    delay(175);
    digitalWrite(36,LOW);
    switch (Bank){
    case 0:
      Bank = 127;
    default:
      Bank--; // reads bank down button
    }
    digitalWrite(Bank_down, HIGH);
  }
  if((digitalRead(Bank_up)==LOW) &&(BANKSTATE[1]==HIGH)){ //bank works very poorly
    digitalWrite(36, HIGH);
    delay(100);
    digitalWrite(36,LOW);
   // switch (Bank){
    //case 127:
    //  Bank = 0;
   // default:
      Bank++; // reads bank up button
   // }
    digitalWrite(Bank_up, HIGH);
  }
  
    if(Bank != Bank_old){
    SWITCHRESET(); // if pressed reset switches & LED's - works
    LCDBANKCHANGE(Bank);
    Bank_old = Bank;
  }


  //check if change in pedals
  
  for(int Ptest=1;Ptest<5;Ptest++){
    PEDALSTATE[Ptest] = analogRead(PEDALS[Ptest]);
    if(PEDALSTATE[Ptest] != PEDALSTATE_OLD[Ptest]){
      MIDIPEDALSEND(PEDALSTATE[Ptest],Bank,Ptest);
    }
  }
  
  AISWITCHPRESS(Bank); //after bank check and pedal check check 13 AI switches seems to work with LEDS
}

void SWITCHRESET(){
  for(int a=1;a<14;a++){
    LEDSTATE[a] = -1;
    digitalWrite(SWITCHES[a], HIGH);
    digitalWrite(LEDS[a], LOW);
    SWITCHSTATES[a] = HIGH;
  }

}

void LCDBANKCHANGE(int bank){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Bank: ");
  lcd.print(bank);
}

void MIDIPEDALSEND(int val, int bank, int Pedal){

  int CC_Designation[4][128]={ //which CC designation does each pedal have? 4 pedals x 128 CC's
    {
      0,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14        }
    ,
    {
      0,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14        }
    ,
    {
      0,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14        }
    ,
    {
      0,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14        }
  };
  int CH_designation[4][128]={
    {
      0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2        }
    ,
    {
      0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2        }
    ,
    {
      0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2        }
    ,
    {
      0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2        }
    ,
  };

 // MIDI.send(CC,CC_Designation[Pedal][Bank],val,CH_designation[Pedal][Bank]); //with this commented out, no TX problem, but no Bank response
}

void AISWITCHPRESS(int Bank){
  for(int a=1;a<16;a++){
    if ((digitalRead(SWITCHES[a])==LOW)&& (SWITCHSTATES[a] == HIGH)){
      LEDSTATE[a]=LEDSTATE[a]*(-1);
      delay(175); //RELEASE TIME - varies depending on program size. allows for release to only trigger one change.
      //Break at this point, need to send to MASTER AI BANK CHANGE program
      //where Switch #, LEDSTATE, SWITCH assignment is taken into account and then sorted out what to do
      MASTERSWITCHER(a, Bank);

    }
    if(SWITCHVAR_OLD[a] != SWITCHVAR[a]){
      //MIDISEND(e,SWITCHVAR[e]);
      SWITCHVAR_OLD[a]=SWITCHVAR[a];
    }

  }
  for(int f=1;f<16;f++){ //this part resets the switches to high
    digitalWrite(SWITCHES[f], HIGH);
    SWITCHSTATES[f] = HIGH;
  }
}

void MASTERSWITCHER(int Switch, int Bank) { //this program needs to read the switch & bank value, and spit out correct
                                            // midi message and LED display.
  if (LEDSTATE[Switch] <0){
    SWITCHVAR[Switch] =0;
    digitalWrite(LEDS[Switch],LOW); //writes to LED, need to change for MAIN BANK/AI Program
  }
  else {
    SWITCHVAR[Switch] = 127;
    digitalWrite(LEDS[Switch], HIGH);
  }

}



12  Forum 2005-2010 (read only) / Troubleshooting / Re: Problem with buttons.. please help on: December 08, 2010, 10:44:51 am
Ok so I was stupid and wired the buttons wrong, but i ended up using pinMode as INPUT and digital Write HIGH to the button input and grounding the other side and everything works fine.

I played around with my code yesterday for a while and kept on building up, but now i'm at a point where one of the buttons works right away, but another works seldom. Please note i tested both buttons with a simple button test program i wrote and they work fine, its this bit of code that the "bank_up" button only works here and there, not every press:

Note i've tried several configurations of this code, but still, no luck.
Code:
int Bank = 0;
int Bank_old = 0;

void loop() { //MAIN LOOP


  if((digitalRead(Bank_down)==LOW) &&(BANKSTATE[2]==HIGH)){// bank down works
    delay(175);
    switch (Bank){
    case 0:
      Bank = 127;
    default:
      Bank--; // reads bank down button
    }
    digitalWrite(Bank_down, HIGH);
  }
  if((digitalRead(Bank_up)==LOW) &&(BANKSTATE[1]==HIGH)){ //bank works very poorly
    delay(175);
    switch (Bank){
    case 127:
      Bank = 0;
    default:
      Bank++; // reads bank up button
    }
    digitalWrite(Bank_up, HIGH);
  }
    if(Bank != Bank_old){
    SWITCHRESET(); // if pressed reset switches & LED's - works
    LCDBANKCHANGE(Bank);
    Bank_old = Bank;
  }


  //check if change in pedals
  
  for(int Ptest=1;Ptest<5;Ptest++){
    PEDALSTATE[Ptest] = analogRead(PEDALS[Ptest]);
    if(PEDALSTATE[Ptest] != PEDALSTATE_OLD[Ptest]){
      MIDIPEDALSEND(PEDALSTATE[Ptest],Bank,Ptest);
    }
  }
  
  AISWITCHPRESS(Bank); //after bank check and pedal check check 13 AI switches seems to work with LEDS
}
13  Forum 2005-2010 (read only) / Troubleshooting / Problem with buttons.. please help on: December 06, 2010, 10:21:53 pm
Hello there, I am trying to initialize a matrix of momentary switches each connected to digital pins of the Mega, and other side to ground, I initialize the switch pins as INPUT & HIGH so that the main loop checks if the are LOW when pressed and grounded momentarily, but for some reason this does not work, heres the test code for 1 switch & 1 LED, should i supply the otherside of the switch with +5v instead of ground?
Code:
void setup() {
  pinMode(51, INPUT); //switch pin, otherside connected to ground
  pinMode(49, OUTPUT); // LED pin
  digitalWrite(51, HIGH); // Initializes switch pin to high
}
int count = 1;
byte state;
byte state2 = HIGH;

void loop(){
 state = digitalRead(51);
  if(state == LOW){ //if switch is pressed
 count = count*(-1); // count becomes negative vale
  }
   if (count >0) {digitalWrite(49,HIGH);} //if count if 1, LED is on
   else { digitalWrite(49, LOW);} // if count is -1, LED is off
  
  digitalWrite(51,HIGH); // reset input pin
}
14  Forum 2005-2010 (read only) / Syntax & Programs / Re: Interfacing MIDI, reading, and Switching, noobie on: January 13, 2010, 03:41:43 pm
ok so i'm trying to get my LCD to work, i'm using a LMB168NFC for which i found the spec sheet here:
http://www.topwaydisplay.com/Pub/Manual/LMB162NFC-Manual-Rev0.1.pdf

wired like so:

http://www.arduinoshow.com/show/2009/04/interfacing-arduino-with-lcd-using-liquidcrystal-library/

and set up using these instructions:

http://www.ladyada.net/learn/arduino/lcd.html

after i uploaded the program, only one half of the lcd charaters a lit up (blocks) and i get on message, i did edit the cpp file for the lcd.h library, any help?
15  Forum 2005-2010 (read only) / Syntax & Programs / Re: Interfacing MIDI, reading, and Switching, noobie on: January 12, 2010, 02:07:23 pm
Oh forgot to say, I plan on using a momentary push button switch at digital pin 2 that will hold each midi message on the LCD board until pressed, thus the code for digital read at pin 2
Pages: [1] 2