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:
done = radio.read(data, sizeof(data)); this line error bro
ReplyDeletevoid value not ignored as it ought to be
ya if u take it away it can function without needing that line
Deletedone = exit
ReplyDeleteradio.read(data, sizeof(data)); ok!
Loved it
ReplyDeletevoid value not ignored as it ought to be
ReplyDeletehow can i solve this problem
That's error is stubborn what's the answer for this error
Deletedone = radio.read(data, sizeof(data)); this line error bro
ReplyDeleteReceiver code is displaying
ReplyDeleteVoid value not ignored as it ought to be help my phone is 0777661032 what's app