Rising edge detection

Good day! I hope somebody could help me with this. Here's what I wanna happen. I have LED as output (with MIDI interface also so that the as the LED turns on, the MIDI will play a sound ) and push button as input. I want to trigger the output(LED) ONLY at the rising edge. But with my codes, when I press the button for long then let go of it, the output will be triggered also which is at falling edge. How can I modify my codes for my output to trigger only at the rising edge??

#include <avr/io.h>
  

//void USART_Transmit( unsigned char data );
int ON = 100;//velocity of MIDI notes (between 0 and 127)
int OFF = 0; 
int noteON = 153;//midi note on channel 10 percussion
int note;
volatile uint8_t statedetect = B11111111;



void setup()
{
  //start = false;
  DDRB = 0xFF;             // Set port B as output
  DDRD = 0x00;             // Set port D as input
  PORTD = 0x00;            // Clear Port D pins
  //Set MIDI baud rate:
  //Serial.begin(31250);
  Serial.begin(9600);
}





void loop()
{

 uint8_t changedbits;
 changedbits= PIND ^ statedetect;
 statedetect= PIND;


  if ((changedbits & (1<<PD2))) //If switch1 is pressed
  {
    //while (changedbits & (1<<PD2))
    //{
    note = 35;
    MIDImessage(noteON, note, ON); 
    PORTB = 0x01; //Turns ON LED1
    delay(150);
    MIDImessage(noteON, note, OFF);
    //Bass drum
     
    //Serial.println("On");
    //}
  }
  if (changedbits & (1<<PD3)) //If switch2 is pressed
  {
    //Snare drum
    note = 38;
    MIDImessage(noteON, note, ON); 
    PORTB = 0x02; //Turns ON LED2
    delay(150);
    MIDImessage(noteON, note, OFF); 
    //Serial.println("On");
  }
  if (changedbits & (1<<PD4)) //If switch3 is pressed
  {
    //High Hat
    note = 42;
    MIDImessage(noteON, note, ON); 
    PORTB = 0x04; //Turns ON LED3
    delay(150);
    MIDImessage(noteON, note, OFF);
    
  }
  if (changedbits & (1<<PD5)) //If switch4 is pressed
  {
    //Crash cymbal
    note = 49;
    MIDImessage(noteON, note, ON); 
    PORTB = 0x08; //Turns ON LED4
    delay(150);
    MIDImessage(noteON, note, OFF);
    
  }
  if (changedbits & (1<<PD6)) //If switch5 is pressed
  {
    //right tom
    note = 45;
    MIDImessage(noteON, note, ON);
    PORTB = 0x10; //Turns ON LED5
    delay(150);
    MIDImessage(noteON, note, OFF);
    
  }
  else
  {
    PORTB = 0x00; //Turns OFF LEDs
  }

}

//send MIDI message
void MIDImessage(int command, int MIDInote, int MIDIvelocity) 
{
  USART_Transmit(command);//send note on or note off command
  USART_Transmit(MIDInote);//send note number (determines what drum to play)
  USART_Transmit(MIDIvelocity);//send velocity data

}

void USART_Transmit( unsigned char data )
{
  // Wait for empty transmit buffer 
  while ( !( UCSR0A & (1<<UDRE0)) )
    
  // Put data into buffer, sends the data 
  UDR0 = data;
}

Hi mekay,

This has already been answered in your previous post.

http://forum.arduino.cc/index.php?topic=371862.msg2564435#msg2564435

Please read that link on State Change Detection carefully. The answer is in the State Change Detection example code.