I wrote the code but it doesn't work.
I want to transfer data from midi keyboard to sampler over two arduino nano's and nrf24l01 without cables.
Wrote simple code for communication and it works, that mean the wiring is ok.
I want to use rx pin of one arduino nano to listen midi keyboard command and transfer it to second arduino which one use tx pin to transfer command that receive from first arduino.
Here is the code for Transmiter
#include <SoftwareSerial.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
SoftwareSerial portOne (0, 1);
RF24 radio (7, 8); // CNS, CE
const byte addresses [] [6] = {"1NODE", "2NODE"};
void setup() {
Serial.begin(9600);
portOne.begin(9600);
radio.begin();
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_2MBPS);
radio.setChannel(124);
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(1, addresses[0]);
}
void loop() {
radio.stopListening();
portOne.listen();
while (portOne.available()) {
char inByte = portOne.read();
radio.write(&inByte, sizeof(inByte));
}
Serial.println();
}
Here is for Receiver
#include <SoftwareSerial.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
SoftwareSerial portOne (0, 1);
RF24 radio (7, 8); // CNS, CE
const byte addresses [] [6] = {"1NODE", "2NODE"};
void setup() {
Serial.begin(9600);
portOne.begin(9600);
radio.begin();
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_2MBPS);
radio.setChannel(124);
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(1,addresses[0]);
radio.startListening();
}
void loop() {
unsigned char inByte;
if (radio.available()) {
while (radio.available()) {
radio.read (&inByte, sizeof(inByte));
}
}
Serial.println();
}