Homemade Arduino Based Transmitter and Receiver

by darshanav.todkar in Circuits > Microcontrollers

464 Views, 2 Favorites, 0 Comments

Homemade Arduino Based Transmitter and Receiver

af846d57-affe-416b-9e8c-bb58a1b6d9fe.jpg

This project is for coolest project competition

Before Making Transmitter We Have to Make Body for Transmitter

WhatsApp Image 2021-05-02 at 15.16.01.jpeg

Matarial :

atmage.JPG

Joystick Controller - https://www.amazon.in/Robocraze-Joystick-Module-P...

ATMega328P IC (28 Pins) with 28 pin Base (Controller IC) - https://www.amazon.in/ATMega328P-Pins-pin-Base-Co...

Potentiometer - https://www.amazon.in/AVS-COMPONENTS-Potentiomete...

toggle switch - https://www.amazon.in/Electronic-spices-Electrica...

16.00 MHz Crystal Oscillator with 22pf Capacitor - https://www.amazon.in/16-00-Crystal-Oscillator-22...

5 Volt 1.5 Amp Positive Voltage Regulator - https://www.amazon.in/KTC-CONS-Labs-Positive-Regu...

3.3 Volt Positive Voltage Regulator - https://www.amazon.in/AMS1117-3-3-AMS1117-3-3V-Re...

NRF24L01 with antenna - https://www.amazon.in/NRF24L01-wireless-transceiv...

NRF24L01 without antenna - https://www.amazon.in/KitsGuru-NRF24L01-Wireless-...

10uF capacitors - https://www.amazon.in/ERH-India-20-Pcs-Electrolyt...

General Purpose Printed Circuit Board, 5 Pieces + Female Berg Strip, 5 Pieces + Male Berg Strip - https://www.amazon.in/Generic-B00C743253-Componen...

Matarial :

atmage #!.JPG

ATMega328P IC (28 Pins) with 28 pin Base (Controller IC) - https://www.amazon.in/ATMega328P-Pins-pin-Base-Co...

16.00 MHz Crystal Oscillator with 22pf Capacitor - https://www.amazon.in/16-00-Crystal-Oscillator-22...

NRF24L01 with antenna - https://www.amazon.in/NRF24L01-wireless-transceiv...

NRF24L01 without antenna - https://www.amazon.in/KitsGuru-NRF24L01-Wireless-...

10uF capacitors - https://www.amazon.in/ERH-India-20-Pcs-Electrolyt...

General Purpose Printed Circuit Board, 5 Pieces + Female Berg Strip, 5 Pieces + Male Berg Strip - https://www.amazon.in/Generic-B00C743253-Componen...

Circute Digram Transmeter

soham #####45.JPG

Circute Digram Receiver

soham #####45.JPG

CODE for Transmitter

/* Tranmsitter code for the Arduino Radio control with PWM or PPM output

* Install the NRF24 library to your IDE * Upload this code to the Arduino UNO, NANO, Pro mini (5V,16MHz) * Connect a NRF24 module to it: Module // Arduino UNO,NANO GND -> GND Vcc -> 3.3V CE -> D9 CSN -> D10 CLK -> D13 MOSI -> D11 MISO -> D12

This code transmits 7 channels with data from pins A0, A1, A2, A3, A4, D2 and D3

#include #include //Remember to isntall this bibrry: http://www.electronoobs.com/engarduino_NRF24_lib.php #include

const uint64_t my_radio_pipe = 0xE8E8F0F0E1LL; //Remember that this code should be the same for the receiver

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

// The sizeof this struct should not exceed 32 bytes struct Data_to_be_sent { byte ch1; byte ch2; byte ch3; byte ch4; byte ch5; byte ch6; byte ch7; };

//Create a variable with the structure above and name it sent_data Data_to_be_sent sent_data;

void setup() { radio.begin(); radio.setAutoAck(true); radio.setDataRate(RF24_250KBPS); radio.openWritingPipe(my_radio_pipe);

//Reset each channel value sent_data.ch1 = 127; sent_data.ch2 = 127; sent_data.ch3 = 127; sent_data.ch4 = 127; sent_data.ch5 = 0; sent_data.ch6 = 0; sent_data.ch7 = 0; }

/**************************************************/

void loop() { /*If your channel is reversed, just swap 0 to 255 by 255 to 0 below EXAMPLE: Normal: data.ch1 = map( analogRead(A0), 0, 1024, 0, 255); Reversed: data.ch1 = map( analogRead(A0), 0, 1024, 255, 0); */ sent_data.ch1 = map( analogRead(A0), 0, 1024, 0, 255); sent_data.ch2 = map( analogRead(A1), 0, 1024, 0, 255); sent_data.ch3 = map( analogRead(A2), 0, 1024, 0, 255); sent_data.ch4 = map( analogRead(A3), 0, 1024, 0, 255); sent_data.ch5 = digitalRead(2); sent_data.ch6 = digitalRead(3); sent_data.ch7 = map( analogRead(A4), 0, 1024, 0, 255);

radio.write(&sent_data, sizeof(Data_to_be_sent)); }

CODE for Receiver

#include

#include #include #include //To create PWM signals we need this lybrary

const uint64_t pipeIn = 0xE8E8F0F0E1LL; //Remember that this code is the same as in the transmitter RF24 radio(9, 10); //CSN and CE pins

// The sizeof this struct should not exceed 32 bytes struct Received_data { byte ch1; byte ch2; byte ch3; byte ch4; byte ch5; byte ch6; byte ch7; };

Received_data received_data;

Servo channel_1; Servo channel_2; Servo channel_3; Servo channel_4; Servo channel_5; Servo channel_6; Servo channel_7;

int ch1_value = 0; int ch2_value = 0; int ch3_value = 0; int ch4_value = 0; int ch5_value = 0; int ch6_value = 0; int ch7_value = 0;

void reset_the_Data() { // 'safe' values to use when NO radio input is detected received_data.ch1 = 0; //Throttle (channel 1) to 0 received_data.ch2 = 127; received_data.ch3 = 127; received_data.ch4 = 127; received_data.ch5 = 0; received_data.ch6 = 0; received_data.ch7 = 0; }

/**************************************************/

void setup() { //Attach the servo signal on pins from D2 to D8 channel_1.attach(2); channel_2.attach(3); channel_3.attach(4); channel_4.attach(5); channel_5.attach(6); channel_6.attach(7); channel_7.attach(8); //We reset the received values reset_the_Data();

//Once again, begin and radio configuration radio.begin(); radio.setAutoAck(true); radio.setDataRate(RF24_250KBPS); radio.openReadingPipe(1,pipeIn); //We start the radio comunication radio.startListening();

}

/**************************************************/

unsigned long lastRecvTime = 0;

//We create the function that will read the data each certain time void receive_the_data() { while ( radio.available() ) { radio.read(&received_data, sizeof(Received_data)); lastRecvTime = millis(); //Here we receive the data } }

/**************************************************/

void loop() { //Receive the radio data receive_the_data();

//////////This small if will reset the data if signal is lost for 1 sec. ///////////////////////////////////////////////////////////////////////// unsigned long now = millis(); if ( now - lastRecvTime > 1000 ) { // signal lost? reset_the_Data(); //Go up and change the initial values if you want depending on //your aplications. Put 0 for throttle in case of drones so it won't //fly away }

ch1_value = map(received_data.ch1,0,255,1000,2000); ch2_value = map(received_data.ch2,0,255,1000,2000); ch3_value = map(received_data.ch3,0,255,1000,2000); ch4_value = map(received_data.ch4,0,255,1000,2000); ch5_value = map(received_data.ch5,0,1,1000,2000); ch6_value = map(received_data.ch6,0,1,1000,2000); ch7_value = map(received_data.ch7,0,255,1000,2000);

//Creathe the PWM signals channel_1.writeMicroseconds(ch1_value); channel_2.writeMicroseconds(ch2_value); channel_3.writeMicroseconds(ch3_value); channel_4.writeMicroseconds(ch4_value); channel_5.writeMicroseconds(ch5_value); channel_6.writeMicroseconds(ch6_value); channel_7.writeMicroseconds(ch7_value); }//Loop end

YouTube Channel

7823d9ac-0c06-45df-80eb-37d2dbf4a669.jpg

👍 like

share

and

subscribe

to my channel