Change Padnote

Hallo

Can you help ,please.

I have Drum Kit Kit AI.

I want to cange Padnote

Basic setting is

unsigned char PadNote[6] = {60,61,62,63,64,65}; // MIDI notes from 0 to 127 (Mid C = 60)

I need for examle

unsigned char PadNote[6] = {49,50,61,63,64,65}; // MIDI notes from 0 to 127 (Mid C = 60)

But If I upload new code , nothing is change!!! Still is 60...65

If I change example

,,boolean VelocityFlag = true/false "

Velocity of pads is changed.

Thank you for you help

Mirek
Prague Cz

Can you post all the code?

Here is link .

http://www.spikenzielabs.com/SpikenzieLabs/Serial_MIDI_files/application.windows_2.zip

I uploaded the same code.

One more thing

It is recommended to choose Diecimila / AT mega168

but I must choose arduino dumilanove w/ ATmega 328 board than I can upload .

Here is link .

No, post your code - the actual code you're using.

Use code tags.

I tried post code but is too long/9000 / and I can't send tags
I sorry for trouble I am beginner.:wink:
Link with zip there is file for Arduino.

Thank for you interest.

Here is first 1/3

/ User settable variables			
//*******************************************************************************************************************

unsigned char PadNote[6] = {60,61,62,63,64,65};          // MIDI notes from 0 to 127 (Mid C = 60)

int PadCutOff[6] = {700,700,700,700,700,700};            // Minimum Analog value to cause a drum hit

int MaxPlayTime[6] = {90,90,90,90,90,90};                // Cycles before a 2nd hit is allowed

#define  midichannel	0;                               // MIDI channel from 0 to 15 (+1 in "real world")

boolean VelocityFlag  = false;                           // Velocity ON (true) or OFF (false)

// Number of Drum Pads used
#define NumPads 6                                        // Number of drum pads (and visual feedback leds) used (Up to 6)               <- NEW
// NOTE: Drum pads are numbered from left to right when facing the DKKAI's screw terminals.
// If you are using less than six pads, connected the pads starting from left to right.
// Added to increase the speed of the drum kit by not scanning drum pads that are not used.

// Default LED color values per color per drum pad
int R_pad[6] = {1023,1023,1023,1023,1023,1023,};         // Red color values (0 to 1023, where 0 is off and 1023 is full on)            <- NEW
int G_pad[6] = {0,0,0,0,0,0,};                           // Green
int B_pad[6] = {0,0,0,0,0,0,};                           // Blue
// Note: There are six values for each primary color. The values correspond to the drum pads, that is why there are six values.
//       All the values must be filled, ie inside the {} brackets you must have six values.
//       Make secondary colors by mixed two or more other colors.


//*******************************************************************************************************************
// Internal Use Variables and Constants
//*******************************************************************************************************************

// For the ShiftBrite
#define clockpin 13                                      // CI
#define enablepin 10                                     // EI
#define latchpin 9                                       // LI
#define datapin 11                                       // DI

int LEDChannels[NumPads][3] = {0};
int SB_CommandMode;
int SB_RedCommand;
int SB_GreenCommand;
int SB_BlueCommand;

boolean activePad[6] = {0,0,0,0,0,0};                   // Array of flags of pad currently playing
int PinPlayTime[6] = {0,0,0,0,0,0};                     // Counter since pad started to play

unsigned char status;

int pin = 0;     
int hitavg = 0;
int val = 0;
int val2 = 0;
int *TempColorPtr;
int CurrentColor = 1;

int RPGpin =0 ;

int PlayModeLED = 7;                                    // DKKAI Roadie Led Pins
int NoteSelectLED = 8; 
int AUXSelectLED = 2;
int PadSelectedLED = 3;

int ModeSelectBut = 6;                                  // DKKAI Roadie Button Pins
int UpBut = 5; 
int DownBut = 4;

int SampTime = 100;
int mode = 1;


//*******************************************************************************************************************
// Setup			
//*******************************************************************************************************************

#include <EEPROM.h>

void setup() 
{
  pinMode(ModeSelectBut, INPUT);                         // Set Button Pins to inputs
  pinMode(UpBut, INPUT);
  pinMode(DownBut, INPUT);

  pinMode(PlayModeLED, OUTPUT);                          // Set LED pins to outputs
  pinMode(NoteSelectLED, OUTPUT);
  pinMode(AUXSelectLED, OUTPUT);
  pinMode(PadSelectedLED, OUTPUT);

  digitalWrite(ModeSelectBut, HIGH);                     // Set internal pull-up to high on button pins
  digitalWrite(UpBut, HIGH);
  digitalWrite(DownBut, HIGH);

  digitalWrite(PlayModeLED, HIGH);                       // Default LED state
  digitalWrite(NoteSelectLED, LOW);
  digitalWrite(AUXSelectLED, LOW);
  digitalWrite(PadSelectedLED, LOW);

  delay(250);

  Serial.begin(57600);                                  // connect the serial port Use 31250 for MIDI [default serial DKK 57600]


  val = EEPROM.read(7);                                 // Position 7 in EEPROM used to see if it has Note data 
  if(val != 78)                                         // (if it is not "78" then we never filled EEPROM, do it now.)
  {
    FILLEEPROM();
  } else
  {
    GETNOTESFROMEEPROM();
  }

  pinMode(datapin, OUTPUT);                             // Pin Set-up for Macetech ShiftBrites
  pinMode(latchpin, OUTPUT);
  pinMode(enablepin, OUTPUT);
  pinMode(clockpin, OUTPUT);

  SPCR = (1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0);
  digitalWrite(latchpin, LOW);
  digitalWrite(enablepin, LOW);

  delay(500);
  docolor(0,0,0, 1000);
  docolor(0,0,0, 1000);
  docolor(0,0,0, 1000);
}

2/3

/*******************************************************************************************************************
// Main Program			
//*******************************************************************************************************************

void loop() 
{

  switch (mode) 
  {
  case 1:                                                         // Normal Drum Playing 
    for(int pin=0; pin < NumPads; pin++)
    {
      hitavg = analogRead(pin);                              // read the input pin

        if((hitavg > PadCutOff[pin]))
      {
        if((activePad[pin] == false))
        {
          if(VelocityFlag == true)
          {
            //          hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin]));    // With full range (Too sensitive ?)
            hitavg = (hitavg / 8) -1 ;                                                 // Upper range
          }
          else
          {
            hitavg = 127;
          }

          MIDI_TX(144,PadNote[pin],hitavg); 
          VisualFeedBack(R_pad[pin],G_pad[pin],B_pad[pin], pin);

          PinPlayTime[pin] = 0;
          activePad[pin] = true;
        }
        else
        {
          PinPlayTime[pin] = PinPlayTime[pin] + 1;
        }
      }
      else if((activePad[pin] == true))
      {
        PinPlayTime[pin] = PinPlayTime[pin] + 1;

        if(PinPlayTime[pin] > MaxPlayTime[pin])
        {
          activePad[pin] = false;
          MIDI_TX(128,PadNote[pin],127); 
          VisualFeedBack(0,0,0, pin);

        }
      }
    } 

    val = digitalRead(ModeSelectBut);
    if(val == 0)
    {
      mode = 2;
      digitalWrite(NoteSelectLED, HIGH);
      digitalWrite(PlayModeLED, LOW); 
      digitalWrite(AUXSelectLED, LOW); 
      digitalWrite(PadSelectedLED, LOW); 

      do
      {
        val = digitalRead(ModeSelectBut);
      }
      while(val == 0);
      delay(100);
    }
    break;

    // ---------------------------------------------------------------------------------------

  case 2:                                                 // Re programming NOTEs Mode (wait for a Pad to be selected)
    val = val;

    for(int pin=0; pin < NumPads; pin++)
    {
      hitavg = analogRead(pin);                              // read the input pin

        if((hitavg > PadCutOff[pin]))
      {
        mode = 3;
        RPGpin = pin;
        digitalWrite(PadSelectedLED, HIGH);

      }

      val = digitalRead(ModeSelectBut);
      if(val == 0)
      {
        mode = 4;
        digitalWrite(NoteSelectLED, LOW);
        digitalWrite(PlayModeLED, LOW); 
        digitalWrite(AUXSelectLED, HIGH); 
        digitalWrite(PadSelectedLED, LOW);     

        do
        {
          val = digitalRead(ModeSelectBut);
        }
        while(val == 0);
        delay(100);
      }

    }

    break;

    // ---------------------------------------------------------------------------------------

  case 3:                                                         // Re programming NOTEs Mode
    val = digitalRead(UpBut);
    if(val == 0)
    {
      PadNote[RPGpin] = PadNote[RPGpin]+1;
      if(PadNote[RPGpin] > 127)
      {
        PadNote[RPGpin] = 127;
      }
      MIDI_TX(144,PadNote[RPGpin],127); 
      delay(SampTime);
      MIDI_TX(128,PadNote[RPGpin],0); 

      do
      {
        val = digitalRead(UpBut);
      }
      while(val == 0); 
      delay(100);
    }

    val = digitalRead(DownBut);
    if(val == 0)
    {
      PadNote[RPGpin] = PadNote[RPGpin]-1;
      if(PadNote[RPGpin] < 1)
      {
        PadNote[RPGpin] = 1;
      }
      MIDI_TX(144,PadNote[RPGpin],127); 
      delay(SampTime);
      MIDI_TX(128,PadNote[RPGpin],0);

      do
      {
        val = digitalRead(DownBut);
      }
      while(val == 0); 
      delay(100);
    }

    hitavg = analogRead(RPGpin);                                        // read the input pin
    if((hitavg > PadCutOff[RPGpin]))
    {
      MIDI_TX(144,PadNote[RPGpin],127); 
      delay(SampTime);
      MIDI_TX(128,PadNote[RPGpin],0);
    }

    val = digitalRead(ModeSelectBut);                                   // Exit to normal play
    if(val == 0)
    {
      mode = 1;
      
      FILLEEPROM();

      digitalWrite(NoteSelectLED, LOW);
      digitalWrite(PlayModeLED, HIGH); 
      digitalWrite(AUXSelectLED, LOW); 
      digitalWrite(PadSelectedLED, LOW);  
      do
      {
        val = digitalRead(ModeSelectBut);
      }
      while(val == 0);
      delay(100);
    }
    break;

    // -------------------------------
  case 4:                                                 // Re programming AUX Mode (wait for a Pad to be selected)
    digitalWrite(AUXSelectLED, HIGH); 
    val = val;

    for(int pin=0; pin < NumPads; pin++)
    {
      hitavg = analogRead(pin);                                            // read the input pin

        if((hitavg > PadCutOff[pin]))
      {
        mode = 5;
        RPGpin = pin;
        TempColorPtr = &R_pad[RPGpin];
        VisualFeedBack(1023,0,0, RPGpin);
        digitalWrite(PadSelectedLED, HIGH);
        delay(500);
        VisualFeedBack(R_pad[RPGpin],G_pad[RPGpin],B_pad[RPGpin], RPGpin);

      }

      val = digitalRead(ModeSelectBut);
      if(val == 0)
      {
        mode = 1;
        digitalWrite(NoteSelectLED, LOW);
        digitalWrite(PlayModeLED, HIGH); 
        digitalWrite(AUXSelectLED, LOW); 
        digitalWrite(PadSelectedLED, LOW);       

        do
        {
          val = digitalRead(ModeSelectBut);
        }
        while(val == 0);
        delay(100);
      }

    }

    break;

    // ----

  case 5:                                                 // Re programming AUX Mode
    val = digitalRead(UpBut);
    val2 = digitalRead(DownBut);
    if(val == 0 && val2 != 0)
    {

      *TempColorPtr = *TempColorPtr +100;
      if(*TempColorPtr>1023)
      {
        *TempColorPtr = 1023;
      }
      VisualFeedBack(R_pad[RPGpin],G_pad[RPGpin],B_pad[RPGpin], RPGpin);
    }

    if(val2 == 0 && val != 0)
    {

      *TempColorPtr = *TempColorPtr -100;
      if(*TempColorPtr<0)
      {
        *TempColorPtr = 0;
      }
      VisualFeedBack(R_pad[RPGpin],G_pad[RPGpin],B_pad[RPGpin], RPGpin);

    }   

    if(val2 == 0 && val == 0)
    {    
      CurrentColor = CurrentColor +1;
      if(CurrentColor > 3)
      {
        CurrentColor =1;
      }

      switch (CurrentColor) 
      {
      case 1:  
        VisualFeedBack(0,0,0, RPGpin);
        delay(250);

        TempColorPtr = &R_pad[RPGpin];

        VisualFeedBack(1023,0,0, RPGpin);
        delay(500);
        VisualFeedBack(R_pad[RPGpin],G_pad[RPGpin],B_pad[RPGpin], RPGpin);

        break;
      case 2:  
        VisualFeedBack(0,0,0, RPGpin);
        delay(250);
        TempColorPtr = &G_pad[RPGpin];

        VisualFeedBack(0,1023,0, RPGpin);
        delay(500);
        VisualFeedBack(R_pad[RPGpin],G_pad[RPGpin],B_pad[RPGpin], RPGpin);    

        break;
      case 3: 
        VisualFeedBack(0,0,0, RPGpin);
        delay(250);

        TempColorPtr = &B_pad[RPGpin];

        VisualFeedBack(0,0,1023, RPGpin);
        delay(500);
        VisualFeedBack(R_pad[RPGpin],G_pad[RPGpin],B_pad[RPGpin], RPGpin);    

        break;

      }

    }      

    // ========================

    val = digitalRead(ModeSelectBut);                                          // Exit to normal play
    if(val == 0)
    {
      mode = 1;
      VisualFeedBack(0,0,0, RPGpin);
      digitalWrite(NoteSelectLED, LOW);
      digitalWrite(PlayModeLED, HIGH); 
      digitalWrite(AUXSelectLED, LOW); 
      digitalWrite(PadSelectedLED, LOW);   
      do
      {
        val = digitalRead(ModeSelectBut);
      }
      while(val == 0);
      delay(100);
    }
    delay(250);

    break;
  }
}

3/3

//*******************************************************************************************************************
// Transmit MIDI Message			
//*******************************************************************************************************************
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY) 
{
  status = MESSAGE + midichannel;
  Serial.write(status);
  Serial.write(PITCH);
  Serial.write(VELOCITY);
}


//*******************************************************************************************************************
// Read MIDI notes for drum pads from EEPROM			
//*******************************************************************************************************************
void GETNOTESFROMEEPROM() 
{
  int EEPadd;
  for(int EEPadd=0; EEPadd < 6; EEPadd++)
  {
    PadNote[EEPadd] = EEPROM.read(EEPadd);
  }
}


//*******************************************************************************************************************
// Save changed (or first time run) MIDI notes to EEPROM			
//*******************************************************************************************************************
void FILLEEPROM()                                          // Normally only run once if EEPROM is clear
{
  int EEPadd;
  for(int EEPadd=0; EEPadd < 6; EEPadd++)
  {

    EEPROM.write(EEPadd, PadNote[EEPadd]);
  }
  EEPROM.write(7, 78);                                      // 78 is just a number we selected to show EEPROM was writen
}

//*******************************************************************************************************************
// Update LED colors			
//*******************************************************************************************************************
void SB_SendPacket() {

  if (SB_CommandMode == B01) {
    SB_RedCommand = 120;
    SB_GreenCommand = 100;
    SB_BlueCommand = 100;
  }

  SPDR = SB_CommandMode << 6 | SB_BlueCommand>>4;
  while(!(SPSR & (1<<SPIF)));
  SPDR = SB_BlueCommand<<4 | SB_RedCommand>>6;
  while(!(SPSR & (1<<SPIF)));
  SPDR = SB_RedCommand << 2 | SB_GreenCommand>>8;
  while(!(SPSR & (1<<SPIF)));
  SPDR = SB_GreenCommand;
  while(!(SPSR & (1<<SPIF)));

}

void WriteLEDArray() {

  SB_CommandMode = B00;                                             // Write to PWM control registers
  for (int h = 0;h<NumPads;h++) {
    SB_RedCommand = LEDChannels[h][0];
    SB_GreenCommand = LEDChannels[h][1];
    SB_BlueCommand = LEDChannels[h][2];
    //    SB_SendPacket();
    SPDR = SB_CommandMode << 6 | SB_BlueCommand>>4;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_BlueCommand<<4 | SB_RedCommand>>6;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_RedCommand << 2 | SB_GreenCommand>>8;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_GreenCommand;
    while(!(SPSR & (1<<SPIF)));
  }

  delayMicroseconds(15);
  digitalWrite(latchpin,HIGH);                                     // latch data into registers
  delayMicroseconds(15);
  digitalWrite(latchpin,LOW);

  SB_CommandMode = B01;                                            // Write to current control registers
  for (int z = 0; z < NumPads; z++) SB_SendPacket();
  delayMicroseconds(15);
  digitalWrite(latchpin,HIGH);                                     // latch data into registers
  delayMicroseconds(15);
  digitalWrite(latchpin,LOW);

}

void docolor(int x, int y, int z, int d)
{
  LEDChannels[0][0] = x;
  LEDChannels[0][1] = y;
  LEDChannels[0][2] = z;
  WriteLEDArray();
}

void VisualFeedBack(int x, int y, int z, int padcolor)
{
  LEDChannels[padcolor][0] = x;
  LEDChannels[padcolor][1] = y;
  LEDChannels[padcolor][2] = z;
  WriteLEDArray();
}