RF24 (uint8_t _cepin, uint8_t _cspin) | |
构造函数 | |
void | begin (void) |
初始化 | |
void | startListening (void) |
开始监听指定的通道 | |
void | stopListening (void) |
停止监听 | |
bool | write (const void *buf, uint8_t len) |
向指定通道发送数据 | |
bool | available (void) |
检查是否有接收到数据 | |
bool | read (void *buf, uint8_t len) |
Read the payload. | |
void | openWritingPipe (uint64_t address) |
打开数据发送通道. | |
void | openReadingPipe (uint8_t number, uint64_t address) |
打开数据接收通道. |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* */ #include <SPI.h> #include "nRF24L01.h" #include "RF24.h" RF24 radio(9,10); const uint64_t pipe = 0xE8E8F0F0E1LL; void setup( void ){ Serial.begin(57600); radio.begin(); radio.openWritingPipe(pipe); radio.printDetails(); pinMode(2,INPUT_PULLUP); } char command[6]= "hello" ; void loop( void ) { uint8_t state = ! digitalRead(2); if (digitalRead(2)==LOW){ Serial.print( "Sending..." ); bool ok = radio.write(command,5); if (ok) Serial.println( "successed" ); else Serial.println( "failed" ); } delay(500); } |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <SPI.h> #include "nRF24L01.h" #include "RF24.h" RF24 radio(9,10); const uint64_t pipe = 0xE8E8F0F0E1LL; void setup( void ){ Serial.begin(57600); radio.begin(); radio.openReadingPipe(1,pipe); radio.startListening(); radio.printDetails(); } void loop( void ){ char command[6]; if (radio.available()){ radio.read( command, 5 ); Serial.println(command[0]); delay(500); } } |
void | setRetries (uint8_t delay, uint8_t count) |
Set the number and delay of retries upon failed submit. | |
void | setChannel (uint8_t channel) |
Set RF communication channel. | |
void | setPayloadSize (uint8_t size) |
Set Static Payload Size. | |
uint8_t | getPayloadSize (void) |
Get Static Payload Size. | |
uint8_t | getDynamicPayloadSize (void) |
Get Dynamic Payload Size. | |
void | enableAckPayload (void) |
Enable custom payloads on the acknowledge packets. | |
void | enableDynamicPayloads (void) |
Enable dynamically-sized payloads. | |
bool | isPVariant (void) |
Determine whether the hardware is an nRF24L01+ or not. | |
void | setAutoAck (bool enable) |
Enable or disable auto-acknowlede packets. | |
void | setAutoAck (uint8_t pipe, bool enable) |
Enable or disable auto-acknowlede packets on a per pipeline basis. | |
void | setPALevel (rf24_pa_dbm_e level) |
Set Power Amplifier (PA) level to one of four levels. | |
getPALevel (void) | |
Fetches the current PA level. | |
bool | setDataRate (rf24_datarate_e speed) |
Set the transmission data rate. | |
getDataRate (void) | |
Fetches the transmission data rate. | |
void | setCRCLength (rf24_crclength_e length) |
Set the CRC length. | |
getCRCLength (void) | |
Get the CRC length. | |
void | disableCRC (void) |
Disable CRC validation. |
联系客服