Servo motor controlled by Joystick using Arduino & Transceiver - Wireles...


Circuit Diagram:

Required Components:


Arduino uno/nano - 2 Nos
Battery - 2 Nos
Transceiver - 2 Nos
Servo Motor - 2 Nos
Joystick - 1 Nos


Program Code:

Transmitter Code:

#include <SPI.h>
#include "RF24.h"
#include "nRF24L01.h"

int potpin1 = A1;
int potpin2 = A2;

int data[2];

RF24 radio(9,10);
const uint64_t pipe=0xE8E8F0F0E1LL;

void setup() {
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
}

void loop(){
data[0] = analogRead(potpin1);
data[1] = analogRead(potpin2);

data[0] = map(data[0],0,1023,5,175);
data[1] = map(data[1],0,1023,5,175);

radio.write(data,sizeof(data));
   {
    Serial.println(data[0]);
    Serial.println(data[1]);
    }
}
Receiver Code:

#include <SPI.h>
#include "RF24.h"
#include "nRF24L01.h"
#include <Servo.h>

Servo servo1;
Servo servo2;

RF24 radio(9,10);
const uint64_t pipe=0xE8E8F0F0E1LL;
int data[2];

void setup() {
  servo1.attach(5);
  servo2.attach(6);
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
}

void loop() {
  if(radio.available()){
    bool done = false;
    while (!done){
      done = radio.read(data, sizeof(data));
      servo1.write(data[0]);
      servo2.write(data[1]);
    }
      {
    Serial.println(data[0]);
    Serial.println(data[1]);
    delay(20);
    }
   }
}

Video:



Comments

  1. done = radio.read(data, sizeof(data)); this line error bro


    void value not ignored as it ought to be

    ReplyDelete
    Replies
    1. ya if u take it away it can function without needing that line

      Delete
  2. done = exit

    radio.read(data, sizeof(data)); ok!

    ReplyDelete
  3. void value not ignored as it ought to be

    how can i solve this problem

    ReplyDelete
    Replies
    1. That's error is stubborn what's the answer for this error

      Delete
  4. done = radio.read(data, sizeof(data)); this line error bro

    ReplyDelete
  5. Receiver code is displaying
    Void value not ignored as it ought to be help my phone is 0777661032 what's app

    ReplyDelete

Post a Comment

Popular posts from this blog

DC motor controlled by Joystick using Arduino & L298N Motor driver - Wireless Connection

DC motor controlled by Gyro MPU 6050 using Arduino & L298N Motor driver - Wired Connection