Hi Guys,
I've been trying to solve this all night and still no luck.
My setup consists of a Teensy 3.1 as my reciever and 2 x Arduino Uno as my nodes, Both Unos transmit analog value from A0 and A1 they both transmit on different writing pipes and eventually i will have them both reading from a single pipe of the Teensy.
I recieve both values at my Teensy but they both print in each others sections....
For example A0 of Node 1 will print in A0 of Node 1 and AO of Node 2
Serial.print(Gloveone[0]);
Serial.println(Glovetwo[0]);
Its like the receiver recognizes the value as coming from Node 1 and Node 2
I've been trying and trying to modify code, change pins and nothing is giving me the right solution i just want Gloveone[0] to be recognized as the analogRead(A0) of Node 1 and not Node 2 aswell.
Here is my code for each below, maybe somebody can see a error that i can pursue i'm running out of ideas
Teensy 3.1 Reciever
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipes[3] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0C3LL };
RF24 radio(9, 10);
byte Gloveone[2];
byte Glovetwo[2];
void setup()
{
Serial.begin(9600);
delay(1000);
radio.begin();
radio.openReadingPipe(1,pipes[1]);
radio.openReadingPipe(2,pipes[2]);
radio.startListening();;
}
void loop()
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
done = radio.read( Gloveone, sizeof(Gloveone) );
done = radio.read( Glovetwo, sizeof(Glovetwo) );
Serial.println();
Serial.print("Glove 1.1:");
Serial.print(Gloveone[0]);
Serial.print(" ");
Serial.print("Glove 2.1:");
Serial.println(Glovetwo[0]);
Serial.print("Glove 1.2:");
Serial.print(Gloveone[1]);
Serial.print(" ");
Serial.print("Glove 2.1:");
Serial.print(Glovetwo[1]);
delay(10);
}
}
}
Uno Code 1 - Node 1
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipes[3] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0C3LL };
RF24 radio(9,10);
byte Gloveone[2];
int val1;
int val2;
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipes[2]);
radio.openReadingPipe(1,pipes[0]);
}
void loop()
{
val1 = analogRead(A0);
Gloveone[0] = val1;
val2 = analogRead(A1);
Gloveone[1] = val2;
radio.write( Gloveone, sizeof(Gloveone) );
}
Uno Code 2 - Node 2
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipes[3] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0C3LL };
RF24 radio(9,10);
byte Glovetwo[2];
int val1;
int val2;
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1,pipes[0]);
}
void loop()
{
val1 = analogRead(A0);
Glovetwo[0] = val1;
val2 = analogRead(A1);
Glovetwo[1] = val2;
radio.write( Glovetwo, sizeof(Glovetwo) );
}