This post is sponsored by PCBWay which is great PCB manufacturing company with the best quality PCB that you can get. Get 10 PCB for just $5 at PCBWay:
Click here: https://www.pcbway.com
Here is the code for the receiver:
Or copy Receiver code here:
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeIn = 0xE8E8F0F0E1LL; //Remember that this code is the same as in the transmitter
RF24 radio(7, 8); //CE and CSN pin
struct MyData {
byte throttle;
byte yaw;
byte pitch;
byte roll;
byte AUX1;
byte AUX2;
};
MyData data;
void resetData()
{
data.throttle = 0;
data.yaw = 127;
data.pitch = 127;
data.roll = 127;
data.AUX1 = 0;
data.AUX2 = 0;
}
/**************************************************/
void setup()
{
Serial.begin(9600);
resetData();
radio.begin();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.openReadingPipe(1,pipeIn);
radio.startListening();
}
/**************************************************/
unsigned long lastRecvTime = 0;
void recvData()
{
while ( radio.available() ) {
radio.read(&data, sizeof(MyData));
lastRecvTime = millis();
}
}
/**************************************************/
void loop()
{
recvData();
unsigned long now = millis();
//check if we've lost signal, if we did we reset the values
if ( now - lastRecvTime > 1000 ) {
resetData();
}
analogWrite(3,data.throttle);
}
/**************************************************/
LIST OF COMPONENTS
Click in the links to buy it.
Arduino Pro Mini LINK HERE
Arduino Uno LINK HERE
NRF24L01 SMD LINK HERE
HT7333 LINK HERE
Oscilloscope LINK HERE
soldering iron LINK HERE
FTDI Programmer LINK HERE
MOSFET LINK HERE
Schottky diode LINK HERE
Motor + Gearbox LINK HERE
FTDI Programmer LINK HERE
MOSFET LINK HERE
Schottky diode LINK HERE
Motor + Gearbox LINK HERE
0 Comments
Post a comment