Hello,
As the title suggests, the RX LED on my arduino does not blink whenever i fully connected all 7 ports of nRF24L01+ into the respective pins. However, whenever i pull out one of the pins, ( whether CE, CSN,MOSI,SCK,MISO ), the Serial monitor would then proceed to print the array that i wrote in the code, but clearly wrong data (See the code below).
It was working fine previously, however, once i started to solder the wires on to the arduino itself, this problem occured. I unsoldered everything and now its not working anymore.
I'm not sure if i had short circuit the ports, but just by visually looking, i'm quite sure they're not.
Since there should not be any problem with my code because it worked before, also i did a simple blink test on all my ports to make sure all pins are not shorted.
How else can i troubleshoot this issue?
Edit: The board only has issues with the nRF24L01+ (I tried using another nRF24L01+, same issue), other codes works fine. This is what baffles me.
#include <Adafruit_PWMServoDriver.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
//Defining nrF2401n+ --------------------------------------
RF24 radio(8, 7); // CE, CSN
const byte address[6] = "00001";
//Defining PCA 9685 --------------------------------------------
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
#define SERVOMIN 160
#define SERVOMAX 335
int x_pos;
int y_pos;
int ForkUpButton;
int ForkDownButton;
int ClawGrabButton;
int ClawReleaseButton;
int dataSend[6];
int Left = 0;
int Right = 0;
// motor one ----------------------------------
int enA = 6;
int in1 = A0;
int in2 = A1;
// motor two ---------------------------------
int enB = 5;
int in3 = A2;
int in4 = A3;
void setup() {
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
pwm.begin();
pwm.setPWMFreq(60);
delay(10);
}
void loop() {
if (radio.available())
{
radio.read(&dataSend, sizeof(dataSend));
Serial.println("Available");
Serial.println(dataSend[0]);
Serial.println(dataSend[1]);
Serial.println(dataSend[2]);
Serial.println(dataSend[3]);
Serial.println(dataSend[4]);
ForkUpButton = dataSend[0];
ForkDownButton = dataSend[1];
ClawGrabButton = dataSend[2];
x_pos = dataSend[3];
y_pos = dataSend[4];
// ForkLift Mechanism -----------------------------------
if(ForkUpButton == 1)
{
pwm.setPWM(6, 0, 150);
}
if(ForkDownButton == 1)
{
pwm.setPWM(6, 0, 600);
}
else if(ForkUpButton == 0 && ForkDownButton == 0)
{
pwm.setPWM(6, 0, 4096);
}
// Claw Mechanism ----------------------------------
if(ClawGrabButton == 1)
{
pwm.setPWM(7, 0, 160);
}
else if(ClawGrabButton == 0)
{
pwm.setPWM(7, 0, 380); //strength grip
}
//RC Car Codes ------------------------------------
if (y_pos < 470)
{
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
Left = map(y_pos, 470, 0, 0, 255);
Right = map(y_pos, 470, 0, 0, 255);
}
else if (y_pos > 550)
{
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
Left = map(y_pos, 550, 1023, 0, 255);
Right = map(y_pos, 550, 1023, 0, 255);
}
else
{
Left = 0;
Right = 0;
}
if (x_pos < 470)
{
int xMap = map(x_pos, 470, 0, 0, 255);
Left = Left - xMap;
Right = Right + xMap;
if (Left < 0)
{
Left = 0;
}
if (Right > 255)
{
Right = 255;
}
}
if (x_pos > 550)
{
int xMap = map(x_pos, 550, 1023, 0, 255);
Left = Left + xMap;
Right = Right - xMap;
if (Left > 255)
{
Left = 255;
}
if (Right < 0)
{
Right = 0;
}
}
if (Right < 75)
{
Right = 0;
}
if (Left < 75)
{
Left = 0;
}
analogWrite(enA, Left);
analogWrite(enB, Right);
}
delay(50);
}