Hi everyone,
I tried nRF2401 with 2 arduino uno r3, and they worked well.
Now I'm trying to connect with arduino pro mini 5v-16hz (since I'm working on small portable stuff). Same connection but doesn't work.
The reason why I'm using a 5v arduino pro mini is because I'm also connecting a MPU 6050 GY521 gyroscope with this thing, and the handy GY521 can't work with voltage lower than 5v. The arduino pro mini has no 3.3v vcc so I add a resistor to the 5v vcc and the output turns out to be around 3.0-3.2, I checked the specs of nRF2401, and it seems to be OK. Also since I have only one FTDI cable, so i'm powering up one of the pro mini with a 9v battery. Does anyone catch any potential error? Thanks a lot!!!
I'm testing with simple code like below:
for sender:
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
int msg[1];
RF24 radio(7,8);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void){
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);}
void loop(void){
for (int x=0;x<255;x++){
msg[0] = x;
radio.write(msg, 1);
}
}
for receiver:
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
int msg[1];
RF24 radio(7, 8);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int red = 3;
int green = 5;
int redNeg = 4;
int greenNeg = 6;
int lastmsg = 1;
void setup(void) {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(redNeg, OUTPUT);
pinMode(greenNeg, OUTPUT);
digitalWrite(greenNeg, LOW);
digitalWrite(redNeg, LOW);
}
void loop(void) {
if (radio.available()) {
bool done = false;
while (!done) {
radio.read(msg, 2);
if (msg[0] != lastmsg + 1) {
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
}
else {
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
}
lastmsg = msg[0];
Serial.println(msg[0]);
}
}
else {
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
}
}