-
-
Save emhe3766/b6030957cec9bd9f44902b9c1b3d2ff6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <nRF24L01.h> | |
#include <RF24.h> | |
RF24 radio(8, 9); // CE, CSN | |
const byte Address[6] = "00001"; | |
int X_pin = A0; | |
int Y_pin = A1; | |
// int x_pos; | |
// int Ypot; | |
void setup() { | |
radio.begin(); | |
radio.openWritingPipe(Address); | |
radio.setPALevel(RF24_PA_MIN); | |
radio.stopListening(); | |
Serial.begin(9600); | |
pinMode(X_pin, INPUT); | |
pinMode(Y_pin, INPUT); | |
} | |
void loop() { | |
int Xpot = analogRead(X_pin); | |
// Serial.print("X Analog value: " + String(Xpot)); | |
int Ypot = analogRead(Y_pin); | |
// Serial.println(" Y Analog value: " + String(Ypot)); | |
int values[2]; | |
values[0] = Xpot; | |
values[1] = Ypot; | |
Serial.println(values[0]); | |
Serial.println(values[1]); | |
delay(200); | |
radio.write(values, sizeof(values)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment