I am attempting to create a fencing pocket box using Arduino Nanos and wireless modules. The communication from the modules is fine, but I can't seem to communicate between the ports. The black port is CPost, the middle yellow post is BPost and the bottom yellow post is APost. WHat is supposed to happen is when B is touched to A one signal is outputted, and when B is touched to C a different sidnal is outputted. The code and physical builds are identical, but I need to be able to touch the B post of one to the C post of the other (and vice versa) but it does not work. Any guidance would be appreciated.
#include "nRF24L01.h" //NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24
#include "RF24.h"
#include "SPI.h"
#define APost 2
#define CPost 3
#define BPost 4
int SentMessage[1] = {000};
RF24 radio(9,10); // NRF24L01 used SPI pins + Pin 9 and 10 on the NANO
const uint64_t pipe = 0xE6E6E6E6E6E6; // Needs to be the same for communicating between 2 NRF24L01
void setup()
{
pinMode(APost, INPUT);
pinMode(CPost, INPUT);
pinMode(BPost, OUTPUT);
digitalWrite(APost,HIGH);
digitalWrite(CPost, HIGH);
digitalWrite(BPost, LOW);
radio.begin(); // Start the NRF24L01
radio.openWritingPipe(pipe); // Get NRF24L01 ready to transmit
}
void loop()
{
if (digitalRead(CPost) == LOW) // If switch is pressed
{
SentMessage[0] = 110;
radio.write(SentMessage, 1); // Send pressed data to NRF24L01
}
else if (digitalRead(APost) == LOW)
{
SentMessage[0] = 111;
radio.write(SentMessage, 1);
}
else
{
SentMessage[0] = 000;
radio.write(SentMessage, 1); // Send idle data to NRF24L01
}
delay(2);
}