Radio_FahrzeugV2/Transceiver/Transceiver.ino

30 lines
577 B
Arduino
Raw Normal View History

2023-06-01 15:28:39 +02:00
#include <SPI.h>
#include <RF24.h>
2023-06-01 15:52:34 +02:00
//TODO Sende analoge daten für joystick
2023-06-01 15:28:39 +02:00
RF24 radio(9, 10); // (CE, CSN)
const byte address[6] = "1RF24";
struct dataStruct {
int Xposition;
int Yposition;
2023-06-01 15:28:39 +02:00
} myData;
2023-06-27 18:07:14 +02:00
2023-06-01 15:28:39 +02:00
void setup() {
radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setChannel(50);
2023-06-01 15:28:39 +02:00
radio.openWritingPipe(address);
radio.stopListening();
Serial.begin(9600);
2023-06-01 15:28:39 +02:00
}
void loop() {
// Serial.println(radio.isChipConnected());
myData.Xposition = analogRead(0);
myData.Yposition = analogRead(1);
radio.write(&myData, sizeof(myData), 1);
2023-06-01 15:28:39 +02:00
delay(10);
}