Devices & Components
1
Arduino Uno Rev3
Software & Tools
Arduino IDE
Project description
Code
Code for RC receiver channel read
arduino
Comments
Only logged in users can leave comments
Devices & Components
Arduino Uno Rev3
Software & Tools
Arduino IDE
Project description
Code
Code for RC receiver channel read
arduino
1unsigned long int a,b,c; 2int x[15],ch1[15],ch[7],i; 3//specifing arrays and variables to store values 4 5void setup() { 6Serial.begin(9600); 7 pinMode(2, INPUT_PULLUP); 8 attachInterrupt(digitalPinToInterrupt(2), read_me, FALLING); 9 // enabling interrupt at pin 2 10} 11 12void loop() { 13read_rc(); 14 15Serial.print(ch[1]);Serial.print("\ "); 16Serial.print(ch[2]);Serial.print("\ "); 17Serial.print(ch[3]);Serial.print("\ "); 18Serial.print(ch[4]);Serial.print("\ "); 19Serial.print(ch[5]);Serial.print("\ "); 20Serial.print(ch[6]);Serial.print("\ 21"); 22 23delay(100); 24} 25 26 27void read_me() { 28 //this code reads value from RC reciever from PPM pin (Pin 2 or 3) 29 //this code gives channel values from 0-1000 values 30 // -: ABHILASH :- // 31a=micros(); //store time value a when pin value falling 32c=a-b; //calculating time inbetween two peaks 33b=a; // 34x[i]=c; //storing 15 value in array 35i=i+1; if(i==15){for(int j=0;j<15;j++) {ch1[j]=x[j];} 36 i=0;}}//copy store all values from temporary array another array after 15 reading 37void read_rc(){ 38int i,j,k=0; 39 for(k=14;k>-1;k--){if(ch1[k]>10000){j=k;}} //detecting separation space 10000us in that another array 40 for(i=1;i<=6;i++){ch[i]=(ch1[i+j]-1000);}} //assign 6 channel values after separation space
Comments
Only logged in users can leave comments