Servomotor controlled by Potentiometer using Arduino & Tranceiver - Wire...


Circuit Diagram:

Required Components:


Arduino uno/nano - 2 Nos
Battery - 2 Nos
Transceiver - 2 Nos
Servo Motor - 2 Nos
Potentiometer - 2 Nos


Program Code:

Transmitter Code:

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

int msg[1];
RF24 radio(9,10);
const uint64_t pipe=0xE8E8F0F0E1LL;
int Potpin=A1;
int val;

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

void loop() {
val=analogRead(Potpin);
val=map(val,0,1023,0,179);
msg[0]=val;
radio.write(msg,1);
}

Receiver Code:

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

Servo myservo;
RF24 radio(9,10);
const uint64_t pipe=0xE8E8F0F0E1LL;
int msg[1];

void setup() {
  myservo.attach(5);
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();

}

void loop() {
  if(radio.available()){
    bool done = false;
    while(!done)
    {
      done = radio.read(msg,1);
      myservo.write(msg[0]);
    }
  }
}


Video:

Comments

  1. Please send me the library on my email please

    ReplyDelete
  2. Please make coding for 4 servo motors please

    ReplyDelete
  3. it shows an error

    error: void value not ignored as it ought to be

    done = radio.read(msg,1);

    ^

    Multiple libraries were found for "RF24.h"



    exit status 1

    void value not ignored as it ought to be



    ReplyDelete
    Replies
    1. problem with RF24 library

      download it here https://github.com/maniacbug/RF24

      Delete
  4. code for 10 servo. 7 potentiometers used

    ReplyDelete

Post a Comment

Popular posts from this blog

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

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