Hallo
Ich habe eine Arduino Mini Pro und ein Ardunio Nano.
Beide haben einen NRF24l01 drauf.
Komunikation von Nano zu Mini und umgedreht funktioniert.
Nun möhte ich vom Nano zum Mini Daten senden, der Mini soll dies
auswerten und Daten zurück senden.
Nun meine frage.: Wie mach ich das, das der Mini mir die daten zurück
sendet.
Hier mal ein Beispiel code nur in eine richtung.
Arduino Nano Sender:
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
byte report[12];
unsigned int tmp;
void setup(){
Serial.begin(9600);
Mirf.cePin = 9;
Mirf.csnPin = 10;
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setTADDR((byte*)"cbase");
Mirf.payload = 12;
Mirf.channel = 10;
Mirf.config();
Serial.println("Start ...");
}
void loop(){
while(Mirf.isSending()) {
//delay(5);
}
tmp = 0;
report[0] = (tmp & 0xFF;
report[1] = (tmp & 0xFF00) >> 8;
tmp = 10;
report[2] = (tmp & 0xFF;
report[3] = (tmp & 0xFF00) >> 8;
tmp = 20;
report[4] = (tmp & 0xFF;
report[5] = (tmp & 0xFF00) >> 8;
tmp = 30;
report[6] = tmp & 0xFF;
report[7] = (tmp & 0xFF00) >> 8;
tmp = 40;
report[8] = tmp & 0xFF;
report[9] = (tmp & 0xFF00) >> 8;
tmp = 50;
report[10] = tmp & 0xFF;
report[11] = (tmp & 0xFF00) >> 8;
Mirf.send(report);
delay(20);
}
Arduino Mini Empfänger:
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
byte report[12];
void setup(){
Serial.begin(9600);
Mirf.cePin = 7;
Mirf.csnPin = 8;
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte*)"cbase");
Mirf.payload = 12;
Mirf.channel = 10;
Mirf.config();
Serial.println("Start ...");
}
void loop(){
while(!Mirf.dataReady()) {
delay(5);
}
Mirf.getData(report);
Serial.print(report[0], DEC);
Serial.print(',');
Serial.print(report[1], DEC);
Serial.print(',');
Serial.print(report[2] + (report[3] << 8), DEC);
Serial.print(',');
Serial.print(report[4] + (report[5] << 8), DEC);
Serial.print(',');
Serial.print(report[6] + (report[7] << 8), DEC);
Serial.print(',');
Serial.print(report[8] + (report[9] << 8), DEC);
Serial.print(',');
Serial.print(report[10] + (report[11] << 8), DEC);
Serial.println();
delay(20); // 50Hz
}
Kann ich die daten zurück Senden.?
hat jemand nen beispielcode.?
LG.: Andre
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.