Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- int XPin = A0;
- int YPin = A1;
- int ButtonPin = A3;
- int Array[3];
- RF24 radio(8, 9); // CE, CSN
- const byte address[6] = "00001";
- void setup() {
- Serial.begin(9600);
- pinMode(XPin, INPUT);
- pinMode(YPin, INPUT);
- pinMode(ButtonPin, INPUT_PULLUP);
- radio.begin();
- radio.openWritingPipe(address);
- radio.setPALevel(RF24_PA_MIN);
- radio.stopListening();
- Serial.println("It has begun");
- }
- void loop() {
- Array[0] = analogRead(XPin);
- Array[1] = analogRead(YPin);
- if (digitalRead(ButtonPin) == HIGH) {
- Array[2] = 0;
- }
- else {
- Array[2] = 1;
- }
- radio.write(&Array, sizeof(Array));
- Serial.print("X: ");
- Serial.println(Array[0]);
- Serial.print("Y: ");
- Serial.println(Array[1]);
- Serial.print("Btn: ");
- Serial.println(Array[2]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement