I made some custom pcb's and am now able to communicate using two rf22 radios and two arduino pro mini's 5v.
i have loaded the client and server on them and have succesful comms using the examples.
What I would like to do is just have a pushbutton on one of the server board, and have it light an LED on the client arduino.
I am confused as to how to transmit a digital pushbutton status over this type of communications:
if (!rf22.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
Serial.println("sendtoWait failed");
else
{
// Now wait for a reply from the server
// Serial.println(rf22.lastRssi(), HEX); // of the ACK
uint8_t len = sizeof(buf);
uint8_t from;
if (rf22.recvfromAckTimeout(buf, &len, 2000, &from))
{
Serial.print("got reply from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
}
else
{
Serial.println("No reply, is rf22_datagram_server running?");
}
}
delay(500);
}
I have found this example:
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
}
if( val == 'H' ) // if 'H' was received
{
digitalWrite(ledpin, HIGH); // turn ON the LED
} else {
digitalWrite(ledpin, LOW); // otherwise turn it OFF
}
delay(100); // wait 100ms for next reading
}
But I haven't been able to figure out how to translate it to the rf22 code.
I also have not been able to find any successful tutorials for a basic thing such as this, if i knew how to transmit basic functions im pretty sure i could take it from there.