کد سمت فرستنتون یه مقدار زیادی داشت :
کد:
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
RF24 radio(7, 8);
const byte address[6] = "00001";
//////////////////////////////////
int joyStick[1]={
1};
#include <avr/sleep.h>
void setup()
{
radio.begin();
radio.setRetries(15, 15);//trans data in 3.75ms and try for 15 times
radio.openWritingPipe(address);
attachInterrupt(0, pinInterrupt, LOW);
}
void loop()
{
sleepSetup();
}
void sleepSetup()
{
sleep_enable();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_cpu();
}
void pinInterrupt()//ISR
{
sleep_disable();
radio.write(joyStick, sizeof(joyStick));
detachInterrupt(0);
}