HI, I'm using a nRF24L01 to send a value between to Arduino's. The problem is on the receiver side the data is in an array format. I want to have the value stored as a regular int. How do you convert an array like this to a regular int?
I am new to this so.. would there be a way just to transmit the INT not in an array format?
This is the receiver
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
char rec[16];
int data[16];
int numbers[3];
void setup(){
Serial.begin(9600);
pinMode(4, OUTPUT);
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)"serv1");
Mirf.payload = 16;
char data[Mirf.payload];
Mirf.config();
}
void loop(){
data[Mirf.payload];
if(!Mirf.isSending() && Mirf.dataReady()){
}
while(!Mirf.dataReady()){
}
Mirf.getData((byte *) &rec);
Serial.print(rec[0]);
Serial.print(rec[1]);
Serial.println(rec[2]);
}
Here is the transmitter
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
int rate = 0;
char buffer[16];
char data[16];
void setup(){
Serial.begin(9600);
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)"clie1");
Mirf.payload = 16;
Mirf.config();
}
void loop(){
rate = rate + 1;
Mirf.setTADDR((byte *)"serv1");
data[Mirf.payload];
sprintf(buffer,"%1d",rate);
Mirf.send((byte *) &buffer);
while(Mirf.isSending()){
}
delay(1000);
}