From 036bc02bad39377037d4648f24fabf6c8144267d Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 2 Jun 2019 15:03:53 +0200 Subject: [PATCH] [nRF24] Updated examples --- .../nRF24/nRF24_Receive/nRF24_Receive.ino | 21 ++++++++++++++++--- .../nRF24/nRF24_Transmit/nRF24_Transmit.ino | 19 +++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/examples/nRF24/nRF24_Receive/nRF24_Receive.ino b/examples/nRF24/nRF24_Receive/nRF24_Receive.ino index 1ea09fb9..785ce037 100644 --- a/examples/nRF24/nRF24_Receive/nRF24_Receive.ino +++ b/examples/nRF24/nRF24_Receive/nRF24_Receive.ino @@ -8,13 +8,23 @@ - data rate - transmit pipe on transmitter must match receive pipe on receiver + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// nRF24 is in slot A on the shield -nRF24 nrf = RadioShield.ModuleA; +// nRF24 has the following connections: +// NSS pin: 10 +// CE pin: 2 +// IRQ pin: 3 +nRF24 nrf = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//nRF24 nrf = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -35,7 +45,7 @@ void setup() { } // set receive pipe 0 address - // NOTE: address width in bytes MUST be equal to the + // NOTE: address width in bytes MUST be equal to the // width set in begin() or setAddressWidth() // methods (5 by default) Serial.print(F("[nRF24] Setting address for receive pipe 0 ... ")); @@ -78,5 +88,10 @@ void loop() { // timeout occurred while waiting for a packet Serial.println(F("timeout!")); + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + } } diff --git a/examples/nRF24/nRF24_Transmit/nRF24_Transmit.ino b/examples/nRF24/nRF24_Transmit/nRF24_Transmit.ino index 304ab6b1..d6c19f05 100644 --- a/examples/nRF24/nRF24_Transmit/nRF24_Transmit.ino +++ b/examples/nRF24/nRF24_Transmit/nRF24_Transmit.ino @@ -8,13 +8,23 @@ - arbitrary binary data (byte array) Packet delivery is automatically acknowledged by the receiver. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// nRF24 is in slot A on the shield -nRF24 nrf = RadioShield.ModuleA; +// nRF24 has the following connections: +// NSS pin: 10 +// CE pin: 2 +// IRQ pin: 3 +nRF24 nrf = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//nRF24 nrf = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -74,6 +84,11 @@ void loop() { // timed out while transmitting Serial.println(F("timeout!")); + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + } // wait for a second before transmitting again