Your code uses an if/then/else for really no good reason in the example you shared. This is IMHO easier to read and maintain as well as smaller. You cache the button state twice; once in buttonState and then again in the first byte of buf. Probably the compiler is smart enough to make these optimizations but tight coding is just good practice.
if(cycleState == true ) {
buttonState = digitalRead(buttonPin);
radio.send(TONODEID, buttonState, 1);
buttonState ? Serial.println("True sent") : Serial.println("False sent");
cycleStart = false;
digitalWrite(LED, HIGH);
_delay_ms(50);
digitalWrite(LED, LOW);
}
@ChemE, you are correct that the state of the button doesn't need to be tested as the actual state is being transmitted to the other end.
Unfortunately, I'm sorry to say, this is close but no cigar.
radio.send() needs an address of the variable, so that line should read:
radio.send(TONODEID, &buttonState, 1);
Also, this is where the exchange of data between two entities REQUIRES that both entities agree on what is being sent. In this case, if the two processors (and compilers) are the same, then treating both ends as the same type is ok, but ONLY if you send the correct amount of data. On some processors bool will be larger than a single byte and the previous code could truncate the variable. A safer implementation would be:
radio.send(TONODEID, &buttonState, sizeof(buttonState));
and the receiving code would use a corresponding set of code to retrieve it.
Using an intermediate value of known size, in this case, is not only safe, but sufficiently readable.
uint8_t buttonState = digitalRead(buttonPin);
radio.send(TONODEID, &buttonState, 1);