I did a search on the meaning of RX and TX and it seems TX means sending data and RX means receiving data. So when my transmitter is turned off, my receiver looks like this and it works with a battery:
and when I turn on the transmitter my receiver looks like this:
So Tx is blinking and I'm confused, because Rx is not blinking and I think I receive nothing.
receiver code:
#include <RF24.h>
#include <SPI.h>
int speedpin1=5;
int dir11=3;
int dir12=7;
int speedpin2=A4;
int dir21=8;
int dir22=A3;
int speedpin3=A2;
int dir31=A1;
int dir32=A0;
int speedpin4=2;
int dir41=4;
int dir42=6;
int mspeed;
const byte CE = 9;
const byte CS = 10;
int data[1];
RF24 Radio(CE,CS);
const byte address[6]="00001";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(speedpin1,OUTPUT);
pinMode(dir11,OUTPUT);
pinMode(dir12,OUTPUT);
pinMode(speedpin2,OUTPUT);
pinMode(dir21,OUTPUT);
pinMode(dir22,OUTPUT);
pinMode(speedpin3,OUTPUT);
pinMode(dir31,OUTPUT);
pinMode(dir32,OUTPUT);
pinMode(speedpin4,OUTPUT);
pinMode(dir41,OUTPUT);
pinMode(dir42,OUTPUT);
Radio.begin();
Radio.openReadingPipe(1,address);
Radio.startListening();
}
void loop() {
// put your main code here, to run repeatedly:
if(Radio.available()){
Radio.read(data,sizeof(data));
if (data[0]>131){
digitalWrite(dir41,LOW);
digitalWrite(dir42,HIGH);
analogWrite(dir31,0);
analogWrite(dir32,255);
digitalWrite(dir21,HIGH);
analogWrite(dir22,0);
digitalWrite(dir11,HIGH);
digitalWrite(dir12,LOW);
mspeed=255;
analogWrite(speedpin1,mspeed);
analogWrite(speedpin2,mspeed);
analogWrite(speedpin3,mspeed);
analogWrite(speedpin4,mspeed);
Serial.println(mspeed);
}
if (data[0]<131){
digitalWrite(dir41,HIGH);
digitalWrite(dir42,LOW);
analogWrite(dir31,255);
analogWrite(dir32,0);
digitalWrite(dir21,LOW);
analogWrite(dir22,255);
digitalWrite(dir11,LOW);
digitalWrite(dir12,HIGH);
mspeed=255;
analogWrite(speedpin1,mspeed);
analogWrite(speedpin2,mspeed);
analogWrite(speedpin3,mspeed);
analogWrite(speedpin4,mspeed);
Serial.println(mspeed);
}
if (data[0]==131){
mspeed=0;
analogWrite(speedpin1,mspeed);
analogWrite(speedpin2,mspeed);
analogWrite(speedpin3,mspeed);
analogWrite(speedpin4,mspeed);
Serial.println(mspeed);
}
}
transmitter code:
#include <RF24.h>
#include <SPI.h>
const byte CE = 9;
const byte CS = 10;
int jpin=A0;
int datax;
int data[1];
RF24 Radio(CE,CS);
const byte address[6]="00001";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Radio.begin();
Radio.setRetries(5,10);
Radio.openWritingPipe(address);
}
void loop() {
// put your main code here, to run repeatedly:
datax=analogRead(jpin);
datax=map(datax, 0, 1023, 0, 255);
data[0]=datax;
Serial.print("data x: ");
Serial.println(data[0]);
Radio.write(data,sizeof(data));
}
I'm using nRF2401 and in my transmitter and my receiver the Rx is not blinking and Tx is blinking; why does Rx not blinking?
I also don't know that why does Tx in my receiver not blinking when I move the joystick in my transmitter.
I can control my motors only a few times with a Joystick and after that the Tx in my receiver does not blink and then my motors are keep working or they stop and I can't control them.