Sunday, August 11, 2019

transmitter code for nRF24L01

#include <SPI.h>

#include <RF24_config.h>
#include <RF24.h>
#include <printf.h>
#include <nRF24L01.h>

RF24 radio(7,8);
byte addresses[][6] = {"12"};

typedef struct
{
  int x, y, z;
}dataStruct;
 
 dataStruct data;

 void setup()
 {
   radio.begin();
   radio.openWritingPipe(addresses[0]);
 }
 void loop()
 {
   data.x = analogRead(A0);
   data.y = analogRead(A1);
   data.z = analogRead(A2);
 
   radio.write(&data,sizeof(data));
 
   delay(50);
 
 }

No comments:

Post a Comment