This project is to make a transmitter and receiver just like commercial transmitter and receiver. Use transmitter_with_trim as it has more functions. I'm using Arduino Pro Mini therefore there is a limitation in pins so to use SDA communications , comment A4 & A5 to use SDA communication and vice versa to use Analog pins.
DOWNLOAD CODE - https://github.com/Pie1722/Arduino-Transmitter-Receiver/blob/main/Transmitter_with_trim.ino
-
Libraries: The program uses various libraries, including SPI, nRF24L01, RF24, EEPROM, Wire (for I2C communication), Adafruit_GFX, and Adafruit_SSD1306 (for controlling an OLED display).
-
OLED Display: The code initializes and uses an OLED display (128x64 pixels) to provide information and user feedback. It can display trim values, auxiliary channel values, and system status.
-
Joystick Input: The program reads analog joystick values (X and Y axes) using two analog pins (A0 and A1). It uses a threshold (joystickThreshold) to detect joystick activity.
-
Trim Adjustment: The code defines six trim buttons (trimbut_1 to trimbut_6) and handles their presses to adjust trim values. Trim values are stored in EEPROM memory and are read during setup.
-
IMU Control: The program interfaces with an MPU6050 IMU sensor to obtain accelerometer and gyroscope data. It calculates angle values (pitch and roll) using a complementary filter and maps these angles to control signals. IMU control can be enabled or disabled using a button press.
-
Radio Communication: It sets up and uses an nRF24L01 radio module for wireless communication. It defines a structure (Signal) to represent control signals and sends these signals wirelessly.
-
Sleep Mode: When the joystick is inactive for a specified time (INACTIVITY_TIMEOUT), the program enters a low-power sleep mode to conserve energy. It also turns off the OLED display and onboard LED in sleep mode.
-
Temperature Monitoring: The program reads the temperature from the MPU6050 sensor and can enter sleep mode if the temperature exceeds a certain threshold.
-
EEPROM Usage: Trim values are read from and written to EEPROM memory to persistently store user adjustments.
-
Error Calibration: During setup, the program calculates error values for both the accelerometer and gyroscope readings to compensate for sensor imperfections.
-
Border Mapping: The Border_Map function maps input values to specific ranges, allowing for control signal adjustments based on joystick and IMU readings.
-
Button Handling: It handles button presses for enabling/disabling IMU control and adjusting trim values. It includes debouncing to prevent multiple button presses.
-
Main Loop: The main loop continuously reads the joystick, updates trim values, handles button presses, calculates and sends control signals, manages the OLED display, and enters s leep mode when inactive.
-
Display Control: The program controls the OLED display to show various information, including trim values, auxiliary channel values, and system status.
-
Initialization: Setup initializes various components, including the OLED display, radio module, GPIO pins, and the MPU6050 sensor.
-
ResetData: A function to reset control signals to default values if the connection is lost.
-
Updating Arduino Pro Mini Firmware Using ESP01 with OTA ( Comming Soon! )
Download the below code and customize the code to suit your purpse :)