hi,
i able shut down receiver save current, can't figure out how wake without bringing rx pin 2 gnd.
rx code:
i able shut down receiver save current, can't figure out how wake without bringing rx pin 2 gnd.
rx code:
code: [select]
// **** includes *****
#include <spi.h>
#include "nrf24l01.h"
#include "rf24.h"
#include "printf.h"
#include <avr/sleep.h>
int inputs[3];
rf24 radio(9, 10);
const uint64_t pipe = 0xe8e8f0f0e1ll;
// use pin 2 wake pin
const int wakeuppin = 2;
void wakeup()
{
// cancel sleep precaution
sleep_disable();
// must pin stay low while
detachinterrupt (0);
}
void setup()
{
serial.begin(57600);
printf_begin();
radio.begin();
radio.setdatarate(rf24_250kbps);
radio.setpalevel(rf24_pa_min);
radio.setchannel(3);
radio.printdetails();
radio.openreadingpipe(1, pipe);
radio.startlistening();
pinmode(3, output);
pinmode(4, output);
pinmode(5, output);
pinmode(6, output);
pinmode(7, output);
pinmode(8, output);
pinmode(wakeuppin, input_pullup);
}
void loop()
{
if (radio.available())
{
while (radio.available())
{
radio.read( &inputs, sizeof(inputs) );
//serial.println ("available");
digitalwrite(5, high);
if (inputs[0] == 0)
{
digitalwrite(5, low);
radio.powerdown();
// allow wake pin trigger interrupt on low.
set_sleep_mode (sleep_mode_pwr_down);
sleep_enable();
// not interrupt before go sleep, or the
// isr detach interrupts , won't wake.
nointerrupts ();
// called when pin d2 goes low
attachinterrupt (0, wakeup, low);
interrupts();
sleep_cpu();
}
}
//radio.startlistening();
//radio.powerup();
}
else
{
radio.startlistening();
radio.powerup();
}
}
i read nrf24l01 cannot find examples uses
Arduino Forum > Using Arduino > Programming Questions > Interrupt Access without Hardware
arduino
Comments
Post a Comment