1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
// EMETTEUR
#include "SPI.h"
#include "nRF24L01.h"
#include "RF24.h"
const byte CEPin = 16;
const byte CSNPin = 2;
RF24 radio(4,15);
uint8_t adresse[] = {0xCC, 0xCE, 0xCC, 0xCE, 0xCC};
struct __attribute__ ((packed)) t_message {
char payload[32];
} message;
void setup() {
Serial.begin(9600);
if (!radio.begin()) {
Serial.println(F("erreur !!"));
while (true) ;
}
radio.setPALevel(RF24_PA_LOW);
radio.setPayloadSize(sizeof(t_message));
radio.openWritingPipe(adresse);
strcpy(message.payload, "Hello, world");
//radio.stopListening();
Serial.println(F("PRET"));
}
void loop() {
if (!radio.write( &message, sizeof(t_message) ))
Serial.println(F("erreur d'envoi"));
else
Serial.println(message.payload);
delay(1000);
} |
Partager