Beginning Radio Communications by Alex Wulff

Beginning Radio Communications by Alex Wulff

Author:Alex Wulff
Language: eng
Format: epub
ISBN: 9781484253021
Publisher: Apress


#include <SPI.h>

#include <RF24.h>

// CE, CSN

RF24 radio(9, 10);

int packetID = 0;

const byte addresses[][6] = { "server", "client" };

void setup() {

Serial.begin(9600);

radio.begin();

radio.openWritingPipe(addresses[1]);

radio.openReadingPipe(1,addresses[0]);

radio.setPALevel(RF24_PA_MIN);

}

void loop() {

packetID++; char message[50];

sprintf(message,"Packet ID: %d",packetID);

unsigned long sendTime = micros();

radio.stopListening();

bool stat = radio.write(&message, sizeof(message));

if (stat == 0) {Serial.println("TX Failed!");}

else {Serial.print("Sent Packet ID: "); Serial.println(packetID);}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.