Greetings,
I am a complete beginner in this field and am in the middle of building a RC Car for a class.
Currently I am stuck in that I cant get my single servo motor to respond to the input from a 10k Pot from its transmitter for steering of the RC car. I am certain that I messed up somewhere along the way in the programming and but it could still possibly be the wiring. Checked the Pot and it works fine and serial monitor values change when pot it is turned . Also the throttle works but for some reason the steering remains unresponsive. The wireless module being used is NRF24L01 with 3.3v adapter. Arduino Uno for receiver and Arduino Nano for transmitter. Here are the pinouts. Thank you in advance!
Receiver:
5v-VCC (NRF24L01)
GND-GND (NRF24L01)
GND-ESC GND
VIN-ESC 5v
A0-SERVO VCC
GND-SERVO GND
13-SCK (NRF24L01)
12-M1 (NRF24L01)
11-MO (NRF24L01)
9- OUTPUT SERVO
8-CSN (NRF24L01)
7-CE (NRF24L01)
3-ESC OUTPUT
Transmitter:
GND- GND of 10k Pot(steering) and 10k Pot(throttle)
7-CE (NRF24L01)
8-CSN (NRF24L01)
11-MO (NRF24L01)
12-M1 (NRF24L01)
GND-GND (NRF24L01)
5V-10K Pot(steering), 10K Pot(throttle), and VCC (NRF24L01)
A1-OUTPUTPot(throttle)
A0-OUTPUT Pot(steering)
13-SCK (NRF24L01)
sorry can only post one picture as new user.
--------------------receiver code----------------
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
#define VCC4 A0 //links analog0 with servoVCC
Servo esc;
Servo servo;
RF24 radio(7, 8); // wifi modules pins(CE, CSN) are connected to pins (7, 8)
const byte addresses[][6] = {"node1", "node2"};
byte wewe;
struct MyData {
int state1;
int state2;
int state3;
int state4;
};
MyData data;
int vel;
void resetData()
{
data.state1 = 0;
data.state2 = 0;
data.state3 = 0;
data.state4 = 0;
}
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, addresses [0]);
radio.setPALevel(RF24_PA_MIN);
servo.attach(9); //command pin of the steering servo is connected to pin9
esc.attach(3); //esc signal pin connected to pin3
esc.writeMicroseconds(1000); //initialize the signal to 1000
pinMode(VCC4, OUTPUT); //sets servoVCC to output
}
void loop() {
radio.startListening();
if (radio.available()) {
radio.read(&data, sizeof(MyData));
}
//motor speed control
if (data.state1 > 710) vel = 900; //710 you will have to change this value, based on your potentiometer signal
if (data.state1<710 and data.state1>640) vel = 2000 - (data.state1 - 640) * 13; //710 and 640 you will have to change this values, based on your potentiometer signal
if (data.state1 < 640) vel = 2000; //640 you will have to change this value, based on your potentiometer signal
esc.writeMicroseconds(vel);
//steering servo control
if (data.state2<460){ //460 you will have to change this value, based on your potentiometer signal
wewe=107+(460-data.state2)/12; //107 is the 0 angle of my steering servo
}
if (data.state2>540){//540 you will have to change this value, based on your potentiometer signal
wewe=107-(data.state2-540)/12;
}
if (data.state2>460 and data.state2<540) wewe=107;//460 and 540 you will have to change this values, based on your potentiometer signal
Serial.println (vel);
servo.write (wewe);
digitalWrite(VCC4, HIGH); //supplies servoVCC with 5v
}
--------------Transmitter Code---------
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); //wifi module pins (CE, CSN) are connected to pins (D7,D8) of the arduino
struct MyData {
int state1;
int state2;
int state3;
int state4;
};
MyData data;
void resetData()
{
data.state1 = 0;
data.state2 = 0;
data.state3 = 0;
data.state4 = 0;
}
const byte address[6] = "node1";
void setup() {
pinMode (14, INPUT); // steering potentiometer output is connected to A0
pinMode (15, INPUT); // throttle potentiometer output is connected to A1
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
Serial.begin (9600);
}
void loop() {
radio.stopListening();
data.state1= analogRead(15); //sends throttle data to receiver
data.state2=analogRead(14); //sends steering data to receiver
Serial.println (data.state1);
radio.write (&data,sizeof(MyData));
delay(1);
}

