Hi guys its me again and havig problem about sending data in multiple pipes of nrf24l01. on the transmitter side i can read my commands on serial monitor without any issue however on the rx side, radios are communicating but dont do my commands from the tx side. I am planning to use 1 tx and 3 rx modules and I wrote 3 pipes.rx codes are gonna be same with only pipe numbers changed. I get Nothing happens message on the rx side. Is it because of the pipes?
#include <Bounce2.h>
#include <SPI.h> /////TX
#include "nRF24L01.h"
#include "RF24.h"
byte msg[1];
RF24 radio(9, 10);
const uint64_t pipe[3] = {0xE8E8F0F0E1LL, 0xE8E8F0F0E2LL, 0xE8E8F0F0E3LL};
byte Select_sitstart = 3;
byte Select_onfoot = 4;
byte OnYourMarks = 8; //bounce
byte Set = 7; //bounce
byte Reset = 6; //bounce
byte GunSensor = 5; //bounce
Bounce OYM = Bounce();
Bounce set_one = Bounce();
Bounce reset_one = Bounce();
Bounce gun_one = Bounce();
void setup(void)
{
pinMode(GunSensor, INPUT);
pinMode(Select_sitstart, INPUT);
pinMode(Select_onfoot, INPUT);
pinMode(OnYourMarks, INPUT);
pinMode(Set, INPUT);
pinMode(Reset, INPUT);
OYM.attach(OnYourMarks);
set_one.attach(Set);
reset_one.attach(Reset);
gun_one.attach(GunSensor);
OYM.interval(10);
set_one.interval(10);
reset_one.interval(10);
gun_one.interval(10);
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe[1]);
radio.openWritingPipe(pipe[2]);
radio.openWritingPipe(pipe[3]);
radio.setChannel(108);
radio.setDataRate(RF24_1MBPS);
radio.setPALevel(RF24_PA_HIGH);
}
void loop(void)
{
byte sit = digitalRead(Select_sitstart);
byte foot = digitalRead(Select_onfoot);
OYM.update();
set_one.update();
reset_one.update();
gun_one.update();
byte val_oym = OYM.read();
byte val_set = set_one.read();
byte val_reset = reset_one.read();
byte val_gun = gun_one.read();
if (sit == HIGH)
{
//Serial.println("SITSTART");
//delay(500);
if (val_oym == HIGH)
{
msg[0] = 111; //// poles red
radio.write(msg, 1);
Serial.println(msg[0]);
}
if (val_set == HIGH)
{
msg[0] = 112; //// ground yellow
radio.write(msg, 1);
Serial.println(msg[0]);
}
if (val_gun == HIGH) ///////NORMALLY CLOSED !!!
{
msg[0] = 113; //// ground green
radio.write(msg, 1);
Serial.println(msg[0]);
}
if (val_reset == HIGH)
{
msg[0] = 114;
radio.write(msg, 1);
Serial.println(msg[0]);
}
}
////////////////////////////////////////////////////////////////////////
if (foot == HIGH)
{
//Serial.println("ONFOOT");
//delay(500);
if (val_oym == HIGH)
{
msg[0] = 111; //// poles red
radio.write(msg, 1);
Serial.println(msg[0]);
}
if (val_gun == HIGH) ///////NORMALLY CLOSED !!!
{
msg[0] = 113; //// pole green
radio.write(msg, 1);
Serial.println(msg[0]);
}
if (val_reset == HIGH)
{
msg[0] = 114;
radio.write(msg, 1);
Serial.println(msg[0]);
}
}
}
#include <Bounce2.h>
/////RX
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
byte msg[1];
RF24 radio(9, 10);
const uint64_t pipe[3] = {0xE8E8F0F0E1LL, 0xE8E8F0F0E2LL, 0xE8E8F0F0E3LL};
byte green_mos_gnd = 3; ////ground leds
byte orange_mos_gnd = 4;
byte green_mos_pole = 5; //// pole leds
byte red_mos_pole = 6;
void setup(void) {
pinMode(green_mos_gnd, OUTPUT);
pinMode(orange_mos_gnd, OUTPUT);
pinMode(green_mos_pole, OUTPUT);
pinMode(red_mos_pole, OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(2,pipe[2]);
radio.startListening();
radio.setChannel(108);
radio.setDataRate(RF24_1MBPS);
radio.setPALevel(RF24_PA_HIGH);
}
void loop(void) {
if (radio.available())
{
bool done = false;
while (!done)
{
done = radio.read(msg, 1);
if (msg[0] == 111)
{
delay(10);
digitalWrite(red_mos_pole, HIGH);
Serial.println(msg[0]);
}
if (msg[0] == 112)
{
delay(10);
digitalWrite(orange_mos_gnd, HIGH);
Serial.println(msg[0]);
}
if (msg[0] == 113)
{
delay(10);
digitalWrite(green_mos_gnd, HIGH);
digitalWrite(green_mos_pole, HIGH);
Serial.println(msg[0]);
}
if (msg[0] == 114)
{
delay(10);
digitalWrite(red_mos_pole, LOW);
digitalWrite(green_mos_pole, LOW);
digitalWrite(green_mos_gnd, LOW);
digitalWrite(orange_mos_gnd, LOW);
Serial.println(msg[0]);
}
}
}
Serial.println("nothing else happens");
delay(500);
}