Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano Controlled Joystick with NRF24L01 Wireless Communication

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled Joystick with NRF24L01 Wireless Communication

Circuit Documentation

Summary

This circuit integrates an Arduino Nano microcontroller with a KY-023 Dual Axis Joystick Module, an NRF24L01 wireless transceiver module, an electrolytic capacitor, and a 9V battery. The Arduino Nano reads the joystick's position and button state, then transmits this information wirelessly via the NRF24L01 module. The electrolytic capacitor is used to stabilize the power supply to the NRF24L01, which is sensitive to power fluctuations. The 9V battery provides the power source for the circuit.

Component List

Arduino Nano

KY-023 Dual Axis Joystick Module (x2)

NRF24L01

Electrolytic Capacitor

9V Battery

Wiring Details

Arduino Nano

KY-023 Dual Axis Joystick Module

NRF24L01

Electrolytic Capacitor

9V Battery

Documented Code

#include <SPI.h>
#include <RF24.h>

RF24 radio(9, 10); // CE, CSN pins

const int joyXPin = A0;  // Joystick X-axis connected to A0
const int joyYPin = A1;  // Joystick Y-axis connected to A1
const int buttonPin = 2; // Joystick button connected to pin 2

void setup() {
  Serial.begin(9600);      // Initialize serial communication
  pinMode(buttonPin, INPUT_PULLUP); // Set the button pin as input with pull-up resistor
  radio.begin();
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.setPALevel(RF24_PA_HIGH);
  radio.setDataRate(RF24_1MBPS);
}

void loop() {
  int xValue = analogRead(joyXPin);  // Read X-axis value
  int yValue = analogRead(joyYPin);  // Read Y-axis value
  bool buttonState = digitalRead(buttonPin);  // Read button state

  // Print joystick values to serial monitor
  Serial.print("X: ");
  Serial.print(xValue);
  Serial.print(" Y: ");
  Serial.print(yValue);
  Serial.print(" Button: ");
  Serial.println(buttonState == LOW ? "Pressed" : "Released");
  const char text[] = "Hello from Nano!";
  radio.write(&text, sizeof(text));
  Serial.println("Message Sent");
  delay(1000); // 1 second delay
}

This code initializes the NRF24L01 module and sets up the Arduino to read the joystick's position and button state. It then sends a message wirelessly and prints the joystick values to the serial monitor.