I wish to operate a servo via NRF24l01 and Arduino Uno with a potentiometer via another NRF24l01 and Arduino Uno.
I found a code that should work on Make.Robimek.com, but there are some things about it that will not compile to my sketch. I am an utter noob with this, so your help is needed if I am to get this to work. Below is the transmit and receive codes. If someone could point out the problems and assist me in correcting them I would be grateful. I do realize that some of it is in Turkish but I don't know how to fix it.
Transmitter Software:
#include <SPI.h>
#include <nRF24L01p.h>
nRF24L01p verici(7,8);
/* CSN - > 7, CE -> 8 olarak belirlendi */
int pot=A0;
int val;
char pos;
void setup() {
Serial.begin(9600);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
/* SPI başlatıldı */
verici.channel(90);
verici.TXaddress("kontrol");
verici.init();
/* Verici ayarları yapıldı */
}
void loop() {
val = analogRead(pot); /* pot değeri okuma */
pos= map(val,0,1023,0,180);/* servo açısına çevirme */
Serial.print("Servo = ");
Serial.print(pos);
Serial.println(" derece");/* Açı bilgileri ekrana yazdırıldı */
verici.txPL(pos);
boolean gondermedurumu = verici.send(FAST);
/* açı bilgisi nRF24L01'e aktarıldı */
/* Eğer gönderim başarısız olursa göndermedurumu'nun değeri false olacaktır */
if(gondermedurumu==true){
Serial.println("mesaji gonderildi");
}else{
Serial.println("mesaji gonderilemedi");
}
delay(1000);
}
Receiver Software:
#include <SPI.h>
#include <nRF24L01p.h>
#include <Servo.h>
nRF24L01p alici(7,8);
/* CSN - > 7, CE -> 8 olarak belirlendi */
Servo servo1;
void setup(){
Serial.begin(9600);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
/* SPI başlatıldı */
alici.channel(90);
alici.RXaddress("kontrol");
alici.init();
/* Alıcı ayarları yapıldı */
servo1.attach(9);
}
char deger;
void loop(){
while(alici.available()){
/* Modülden veri geldiği sürece while devam edecek */
alici.read();
alici.rxPL(deger);
servo1.write(deger);
}
}