NRF24L01 PART-3 || CONTROLING SERVOS
TRANSMITTER CODE:
RECEIVER CODE:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
Servo myservo1;
Servo myservo2;
Servo myservo3;
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "mkinventions100";
const int servo1 = 2;
const int servo2 = 3;
const int servo3 = 4;
int SERVOS = 0;
void setup() {
myservo1.attach(servo1);
myservo2.attach(servo2);
myservo3.attach(servo3);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop() {
delay(5);
if ( radio.available()) {
SERVO();
}
}
void SERVO(){
while (radio.available()) {
int SERVOS[3];
radio.read(&SERVOS, sizeof(SERVOS));
myservo1.write(SERVOS[0]);
myservo2.write(SERVOS[1]);
myservo3.write(SERVOS[2]);
}
}
0 Comments
Please do not Enter any Spam Link in the Comment Box
Emoji