This is a my first project and my first post as well.
I am working on a project "robotic hand", using an Arduino Mega, 5 servo motors (mg995), nRF24L01. (This is the first part).
A glove, 5 flex sensors, Arduino Uno, and nRF24L01.
I have gone through almost every tutorial and every project similar to mine using the nRF24L01, but nothing seems to work. I couldn't understand the nRF code, besides it doesn't to function the way it's supposed to be. Can someone help me through please?
I would really appreciate it.
- I am using the NRF24L01: same color of wires with the Mega and Uno.
- I am using flex sensors with a 10kohm resistors. ( I just wired two of them so the wiring would be clear)
- I'am using a 9V battery to supply the Mega and a 9V battery to supply the servos as well, but I did not plug them in the pics.
I have tested the servos and they are doing well, shaking and acting strange sometimes but that's something that I can work on later on.
The wiring in the Mega's circuit:
- Blue represents "Ground"
- Red represents "5V"
- Orange represents digital pins "from 2 to 6"
When it comes to flex sensors I have tested them and they are giving me values.
Here s the link from where I got to wire the NRF24L01: http://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/
I have tried this code, I am not quiet sure how correct it is and I don t know how to make the same thing for "5" servos.
//The Reciever.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
RF24 radio(9, 10); // CE, CSN
Servo myServo;
int angle ;
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
myServo.attach(2);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop() {
Serial.println(radio.available()); //Just checking if connects to the other
NRF or not.
delay(500);
if (radio.available()) {
radio.read(&angle, sizeof(angle));
myServo.write(angle);
Serial.println("angle " + angle);
}
}
//The Transmitter.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const int FLEX_PIN = A0;
int angle;
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
pinMode(FLEX_PIN, INPUT);
radio.begin();
radio.openWritingPipe(address); // 00001
radio.setPALevel(RF24_PA_MIN);
radio.stopListening(); //sets module as transmitter
}
void loop() {
int flexADC = analogRead(FLEX_PIN);
angle = map(flexADC, 600, 900,360, 540);
Serial.println(flexADC);
Serial.println(angle);
delay(200);
radio.write(&angle, sizeof(angle));
}
(I have changed the wiring of the nRF in the Mega, where it is wrong in the pic I have uploaded.)






