├── .gitattributes ├── .gitignore └── Tx_8CH_V2_public.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Tx_8CH_V2_public.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 2.4G Transmitter nRF24L01 module Arduino 3 | 8 Channel Radio Control 4 | Written by: Pason Tanpaiboon 5 | November 2016 6 | Version.1.3 7 | Receiver sketch Rx_8CH_gripper_arm_robot_V1 8 | 9 | This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. 10 | To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ 11 | or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. 12 | */ 13 | 14 | #include 15 | #include "nRF24L01.h" 16 | #include "RF24.h" 17 | 18 | RF24 radio(9,10); 19 | 20 | uint8_t data[9] ; //8 data ptt 21 | const uint8_t buffer_size = sizeof(data); 22 | const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };//two pipes communication 23 | 24 | const int Ail_pot = A1;//Aileron 25 | const int Ele_pot= A2;//Elevator 26 | const int Thr_pot = A3;//Throttle 27 | const int Rud_pot = A4;//Rudder 28 | const int Th_hold = 7;//Throttle hold 29 | const int Th_hold_LED = 3;//Th Hold LED 30 | 31 | const int Aux1_pot = A5;// Auxillary 32 | const int Aux2_pot = A6;// Auxillary 33 | const int Aux3_pot = A7;// Auxillary 34 | const int Aux4_pot = A0;// Auxillary 35 | 36 | int Ail_value = 0; 37 | int Ele_value = 0; 38 | int Thr_value = 0; 39 | int Rud_value = 0; 40 | int Th_hold_value = 0; 41 | 42 | int Aux1_value = 0; 43 | int Aux2_value = 0; 44 | int Aux3_value = 0; 45 | int Aux4_value = 0; 46 | 47 | void setup(void) 48 | { 49 | Serial.begin(115200); 50 | pinMode(Ail_pot,INPUT ); 51 | pinMode(Ele_pot,INPUT ); 52 | pinMode(Thr_pot,INPUT ); 53 | pinMode(Rud_pot,INPUT ); 54 | pinMode(Th_hold,INPUT ); 55 | 56 | pinMode(Aux1_pot,INPUT ); 57 | pinMode(Aux2_pot,INPUT ); 58 | pinMode(Aux3_pot,INPUT ); 59 | pinMode(Aux4_pot,INPUT ); 60 | 61 | pinMode(Th_hold_LED,OUTPUT ); 62 | 63 | radio.begin(); 64 | 65 | radio.setDataRate(RF24_250KBPS); 66 | radio.setPALevel(RF24_PA_MAX); 67 | radio.setChannel(108); 68 | radio.setCRCLength(RF24_CRC_8); 69 | 70 | radio.setRetries(15,15); 71 | radio.openReadingPipe(1,pipes[1]); 72 | radio.startListening(); 73 | radio.printDetails(); 74 | radio.openWritingPipe(pipes[0]); 75 | radio.openReadingPipe(1,pipes[1]); 76 | radio.stopListening(); 77 | 78 | } 79 | 80 | void loop(void) 81 | { 82 | //////////////////////////////////////////////////////////////////////// 83 | Ail_value = analogRead(Ail_pot); 84 | Ail_value = Ail_value/10; 85 | data[0] = Ail_value; 86 | 87 | //////////////////////////////////////////////////////////////////////// 88 | Ele_value = analogRead(Ele_pot); 89 | 90 | data[1] = Ele_value/10;//scaling escval 91 | 92 | //////////////////////////////////////////////////////////////////////// 93 | Thr_value = analogRead(Thr_pot); 94 | 95 | 96 | data[2] = Thr_value/10;//scaling escval 97 | 98 | //////////////////////////////////////////////////////////////////////// 99 | Rud_value = analogRead(Rud_pot); 100 | 101 | 102 | data[3] = Rud_value/10;//scaling escval 103 | 104 | //////////////////////////////////////////////////////////////////////// 105 | Aux1_value = analogRead(Aux1_pot); 106 | 107 | data[4] = Aux1_value/10;//scaling escval 108 | 109 | //////////////////////////////////////////////////////////////////////// 110 | Aux2_value = analogRead(Aux2_pot); 111 | 112 | data[5] = Aux2_value/10;//scaling escval 113 | 114 | //////////////////////////////////////////////////////////////////////// 115 | Aux3_value = analogRead(Aux3_pot); 116 | 117 | data[6] = Aux3_value/10;//scaling escval 118 | 119 | //////////////////////////////////////////////////////////////////////// 120 | Aux4_value = analogRead(Aux4_pot); 121 | 122 | data[7] = Aux4_value/10;//scaling escval 123 | 124 | ///////////////////////////////////////////////////////////////////////// 125 | Th_hold_value = digitalRead(Th_hold); 126 | delay(15); 127 | 128 | if (Th_hold_value == HIGH){ 129 | 130 | data[8] = 1;//Th Hold ON 131 | digitalWrite(Th_hold_LED,HIGH); 132 | 133 | } 134 | else { 135 | data[8] = 0; 136 | digitalWrite(Th_hold_LED,LOW); 137 | } 138 | 139 | ///////////////////////////////////////////////////////////////////////// 140 | 141 | radio.stopListening(); 142 | 143 | bool ok = radio.write( data ,sizeof(data) ); 144 | delay(30); 145 | radio.startListening(); 146 | delay(20); 147 | if (ok){ 148 | Serial.print("data[0]="); 149 | Serial.print(data[0]); 150 | Serial.print(" data[1]="); 151 | Serial.print(data[1]); 152 | Serial.print(" data[2]="); 153 | Serial.print(data[2]); 154 | Serial.print(" data[3]="); 155 | Serial.print(data[3]); 156 | Serial.print(" data[4]="); 157 | Serial.print(data[4]); 158 | Serial.print(" data[5]="); 159 | Serial.print(data[5]); 160 | Serial.print(" data[6]="); 161 | Serial.print(data[6]); 162 | Serial.print(" data[7]="); 163 | Serial.print(data[7]); 164 | Serial.print(" data[8]="); 165 | Serial.println(data[8]); 166 | 167 | } 168 | else 169 | Serial.println("failed\n\r"); 170 | 171 | }//void loop() 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | --------------------------------------------------------------------------------