Arduino interrupt

hey everyone, i'm trying to use interrupts in my project
i'm trying to create UDP communication between 2 Arduinos
i want the Arduino to just to listen if there's i packet is coming and doesn't care about sending
until i make an interrupts , i wrote the following code , but the problem when i push the button it send more than one message it's like going to the interrupts multiple time

the code

#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>



int LED = 7; // for Recving

const int push_ON = 2;
const int push_OFF = 3;
int count = 1;
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
//UDP_TX_PACKET_MAX_SIZE = 24 from EthernetUdp.h;

// network parameters
byte mac[ ] = { 0x90, 0xA2, 0xDA, 0x0E, 0x05, 0x02};  // ethernet interface MAC address

IPAddress localIp(10, 131, 41, 72);    // local ip address

IPAddress destIp(10, 131, 41, 74);      // destination ip address

unsigned int port = 5677;               // destination port
unsigned int localPort = 5678;      // local port to listen on for Recving

// EthernetUDP to send and receive messages.
EthernetUDP Udp;


char message_ON [ ] = "ON" ;
char message_OFF [ ] = "OFF" ;


// setup the arduino and shields
void setup() {

//  pinMode(push_ON, INPUT);
//  pinMode(push_OFF, INPUT);

  attachInterrupt(0, blink, CHANGE);
  attachInterrupt(1, blink, CHANGE);

  //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // start ethernet and udp
  Ethernet.begin(mac, localIp);   // static ip version

  // open UDP port
  Udp.begin(port);

  // show the local ip address (useful for dhcp)
  Serial.print("Local IP: ");
  Serial.println(Ethernet.localIP());


  // now for Recving
  Ethernet.begin(mac, localIp);
  Udp.begin(localPort);
  pinMode(LED, OUTPUT);
  //  Serial.begin(9600);
  Serial.print("Local IP: ");
  Serial.println(Ethernet.localIP());

}

// do tasks
void loop() {


  int packetSize = Udp.parsePacket();

    

//  Serial.println("wait 2 seocnd to cehack if there's packet");
//  delay(2000);
  if (packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i = 0; i < 4; i++)
    {
      Serial.print(remote[i], DEC);
      if (i < 3)
      {
        Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());


    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);

    if (strcmp(packetBuffer, "ON" ) == 0) {
      digitalWrite(LED, HIGH);
    }
    else  if (strcmp(packetBuffer, "OFF" ) == 0) {
      digitalWrite(LED, LOW);
    }

    //to print the packetBuffer
    Serial.print("packetSize is ");
    Serial.println(packetSize);
    Serial.println("the message is: ");
    for (int y = 0; y < packetSize; y++) {
      Serial.print(packetBuffer[y]);
    }
    Serial.println();

    //to clear the buffer
    for (int x = 0 ; x < UDP_TX_PACKET_MAX_SIZE ; x++) {
      packetBuffer[x] = '\0';
    }

    //to know the end of message
    Serial.println("END THE MESSAGE");
  }
}


void blink() {

   if (digitalRead(push_ON) == LOW) {

//    Serial.println("im ON");
    Udp.beginPacket(destIp, port);
    Udp.write(message_ON);
    Udp.endPacket();
//    Serial.println("Sending UDP message");
      

  }

  else if (digitalRead(push_OFF) == LOW) {

//    Serial.println("im OFF");
    Udp.beginPacket(destIp, port);
    Udp.write(message_OFF);
    Udp.endPacket();
//    Serial.println("Sending UDP message");

  

  }
  
}

what's the soulation plases

First of all, why are you using interrupts for this? You can easily check the button states each time through loop(). Second, if you are using interrupts, your function that handles it - Blink() needs to be very small and lightweight. You can't do things like send packets, print debug statements, etc. You should set a variable and then return. Your main program [loop()] needs to check that variable and do the work like sending a packet.

Also, when you push a button, it is quite common to get several transitions from HIGH to LOW as the button begins making physical contact. It is called "bounce". There are many examples on how to "debounce" a button press.

blh64:
First of all, why are you using interrupts for this? You can easily check the button states each time through loop().

if i do that i must hold the button for i while i want to transmit immediately when i press

"immediately" does not mean the same for you and for the Arduino : you can wait a few tens of milliseconds, and during that time the Arduino can do many many things. You won't see any difference even if it's not immediate in a mathematical sense.

khalidd7:
if i do that i must hold the button for i while i want to transmit immediately when i press

That suggests to me that the rest of your code needs to be modified to make it able to respond more quickly to your button-press.

Have a look at how the code is organized in Several Things at a Time

Note how each function runs very briefly and returns to loop() so the next one can be called. None of the functions tries to complete a task in one call. And there may be dozens of calls to a function before it is actually time for it to do anything.

...R