Remote button is too sensitive

Hello I'm trying to use my 4channel wireless module with remote. Everything is working but my remote button is to sensitive. Im using buttonState = digitalRead(buttonPin); to get signal from remote. When I push button light should turn on and when I push it again it should turn off. The problem is that sometimes when I push button light turn on and off. It's very annoying. Is there any code trick which I could use in my sketch to make my button less sensitive? Of course I can use two buttons for one light. One for turn on and another for turn off but I prefer first option :)

const int buttonPin = 12;  
const int ledPin =  13; 

int buttonState = 0;  
int a = 0;

void setup() {
  Serial.begin(9600); 
  pinMode(ledPin, OUTPUT);      
  pinMode(buttonPin, INPUT);     
}

void loop(){
  
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) {     
    if (a == 0) {
     a = 1;
     digitalWrite(ledPin, HIGH); 
    }else {
     a = 0;
     digitalWrite(ledPin, LOW); 
    }    
  } 

}

The problem is noise from button during switching and speed of the program - it is too fast. You need something for button debouncing. There is HW or SW solution. HW with Schmitt trigger. SW with debouncing algorithm - simply ignore changes on I/O which occur too fast. There is plenty libraries for it on the internet search for button debouncing.

First one:

This is it! Now button works perfect. Thanks!

I have one more issue and I dont want to add a new topic. Button works fine when arduino is only looking for digital read of my remote but right now I add a blink with delay(1000). Now when I push button I have to wait a bit for turn light on. There must be a way for those two other functions to do in the same time without waiting. How can I do something like this?

const int buttonPin = 12; 
const int ledPin = 13;  //led for remote
const int ledPin2 = 11;  //led for blink

int ledState = LOW;  
int buttonState;       
int lastButtonState = LOW;  

long lastDebounceTime = 0; 
long debounceDelay = 50;    

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, ledState);
}

void loop() {

  digitalWrite(ledPin2, HIGH);
  delay(1000);
  digitalWrite(ledPin2, LOW);
  delay(1000);
  
  int reading = digitalRead(buttonPin);

  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {

    if (reading != buttonState) {
      buttonState = reading;

      if (buttonState == HIGH) {
        ledState = !ledState;
      }
    }
  }

  digitalWrite(ledPin, ledState);
  lastButtonState = reading;
}

There must be a way for those two other functions to do in the same time without waiting

Study the Blink without delay example that comes with the IDE, or this thread for how to do that.

Thanks it's working! :)

What is more important, transmitter or receiver? I'm using this set: http://botland.com.pl/moduly-radiowe/1733-modul-radiowy-4-kanaly-315-mhz-pilot.html and I have a problem with signal. When I take remote very close to receiver board, remote works fine but when I'm little bit further it's working from time to time. I'm wondering if I buy something more expensive/better quality it will work better? or the problem is somewhere else?