hi friends. at first sorry my bad english. for my wireless car project, i use nrf24l01 and gyro sensor(adxl345). i want to control car with glove. on transmitter arduino i use adxl345 and arduino nano. it creates x,y,z axis succesfully. but when i want to send this values to the reciever , i have problem. if i write "radio.write(data, sizeof(data));" it doesnt work but if i write " radio.write(data, 1); radio.write(data, 2); radio.write(data, 3);" it works but has some problems. x axis value is true, y axis value is true one times but one times its value shows zero. and z axis value is always zero.
i use arduino nano both sides, and all nrf has adapter. can someone help me
--------------Transmitter Code----------
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#define ACC (0xA7>>1) //ADXL345 ACC address
#define A_TO_READ (6) //num of bytes we are going to read each time (two bytes for each axis)
#define CE_PIN 9
#define CSN_PIN 10
int data[3];
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
Wire.begin();
initAcc();
}
void loop()
{
int hx, hy, hz;
int acc[3];
getAccelerometerData(acc);
hx = acc[0];
hy = acc[1];
hz = acc[2];
Serial.print(" X=");
Serial.print(hx);
Serial.print(" Y=");
Serial.print(hy);
Serial.print(" Z=");
Serial.println(hz);
delay(50);
data[0] = hx;
data[1] = hy;
data[2] = hz;
radio.write(data, sizeof(data));
}
.
.
.
(other functions for adxl345)
----------Reciever Code------------
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
int data[3];
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
}
void loop() {
if ( radio.available() )
radio.read( data, sizeof(data) );
Serial.print("x :");
Serial.println(data[0]);
Serial.print("y :");
Serial.println(data[1]);
Serial.print("z :");
Serial.println(data[2]);
}
else
{
Serial.println("No Signal");
}
}


