The attached code starts displaying ZEROS in the serial monitor then it changes to ONES without the button being pressed, can anyone spot my error?
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define buttonPin A0
int buttonState = 0;
RF24 radio(7, 8); // CE, CSN
// SCK - Pin 13, MOSI - Pin 11 & MISO - Pin 12
const byte address[6] = "00002";
void setup() {
pinMode(buttonPin, INPUT);
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == 1)
{
buttonState = 1;
}
else if (buttonState == 0)
{
buttonState = 0;
}
Serial.println(buttonState);
radio.write(&buttonState, sizeof(buttonState));
delay(50);
}
The Receiver side works as it should
Other than that, you can remove the pointless code from digitalRead to Serial.println, you have no debounce.
Thanks for your reply,
I got rid of the code you suggested and the result is still the same, so adding debounce might do the trick, where do I add it?
cheers
Steve
Is the lack of a capacitor likely to cause the issue?
Use any of the dozens of libraries. I did a search on the Arduino.cc site and got this. There are MANY more.
Here is a screen grab showing a library search for button, an example for the button library and some sample code. There are probably more libraries for this than any other function.
try to change this line to:
pinMode(buttonPin, INPUT_PULLUP);
Anthony,
Thank you for your reply, that is exactly what I did before I read your message and it works perfectly.
Cheers
Steve
You're welcome. In that case don't hesitate to set the topic as solved 

Done! thanks for the help!
Steve
If you look at my previous post, there is a picture showing you how to set the topic as solved. What you did is just editing the title 
At the bottom of each post you have a button to select the said post as the solution 