user31093: The code below was taken online and was written for the Arduino Uno. I know C++ however I am a beginner with Arduino so I don't understand this compatibility issue or how to fix it. I am very thankful for any help. Here is part of the code - the variable declarations: (I can upload the entire code if that would be more helpful).
ISR(PCINT0_vect) {
  current_time = micros();
  //Channel 1=========================================
  if(PINB & B00000001) { //Is input 8 high?
    if(last_channel_1 == 0) { //Input 8 changed from 0 to 1.
      last_channel_1 = 1; //Remember current input state.
      timer_1 = current_time; //Set timer_1 to current_time.
    }
  } else if(last_channel_1 == 1) { //Input 8 is not high and changed from 1 to 0.
    last_channel_1 = 0; //Remember current input state.
    receiver_input[1] = current_time - timer_1; //Channel 1 is current_time - timer_1.
  }
  //Channel 2=========================================
  if(PINB & B00000010 ) { //Is input 9 high?
    if(last_channel_2 == 0) { //Input 9 changed from 0 to 1.
      last_channel_2 = 1; //Remember current input state.
      timer_2 = current_time; //Set timer_2 to current_time.
    }
  } else if(last_channel_2 == 1) { //Input 9 is not high and changed from 1 to 0.
    last_channel_2 = 0; //Remember current input state.
    receiver_input[2] = current_time - timer_2; //Channel 2 is current_time - timer_2.
  }
  //Channel 3=========================================
  if(PINB & B00000100 ) { //Is input 10 high?
    if(last_channel_3 == 0) { //Input 10 changed from 0 to 1.
      last_channel_3 = 1; //Remember current input state.
      timer_3 = current_time; //Set timer_3 to current_time.
    }
  } else if(last_channel_3 == 1) { //Input 10 is not high and changed from 1 to 0.
    last_channel_3 = 0; //Remember current input state.
    receiver_input[3] = current_time - timer_3; //Channel 3 is current_time - timer_3.
  }
  //Channel 4=========================================
  if(PINB & B00001000 ) { //Is input 11 high?
    if(last_channel_4 == 0) { //Input 11 changed from 0 to 1.
      last_channel_4 = 1; //Remember current input state.
      timer_4 = current_time; //Set timer_4 to current_time.
    }
  } else if(last_channel_4 == 1) { //Input 11 is not high and changed from 1 to 0.
    last_channel_4 = 0; //Remember current input state.
    receiver_input[4] = current_time - timer_4; //Channel 4 is current_time - timer_4.
  }
}

void set_gyro_registers() {
  //Set up the MPU-6050
  if(eeprom_data[31] == 1) {
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search.
    Wire.write(0x6B); //We want to write to the PWR_MGMT_1 register (6B hex)
    Wire.write(0x00); //Set the register bits as 00000000 to activate the gyro
    Wire.endTransmission(); //End the transmission with the gyro.
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search.
    Wire.write(0x1B); //We want to write to the GYRO_CONFIG register (1B hex)
    Wire.write(0x08); //Set the register bits as 00001000 (500dps full scale)
    Wire.endTransmission(); //End the transmission with the gyro
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search.
    Wire.write(0x1C); //We want to write to the ACCEL_CONFIG register (1A hex)
    Wire.write(0x10); //Set the register bits as 00010000 (+/- 8g full scale range)
    Wire.endTransmission(); //End the transmission with the gyro
    //Let's perform a random register check to see if the values are written correct
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search
    Wire.write(0x1B); //Start reading @ register 0x1B
    Wire.endTransmission(); //End the transmission
    Wire.requestFrom(gyro_address, 1); //Request 1 bytes from the gyro
    while(Wire.available() < 1); //Wait until the 6 bytes are received
    if(Wire.read() != 0x08) { //Check if the value is 0x08
      digitalWrite(12,HIGH); //Turn on the warning led
      while(1)delay(10); //Stay in this loop for ever
    }
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search
    Wire.write(0x1A); //We want to write to the CONFIG register (1A hex)
    Wire.write(0x03); //Set the register bits as 00000011 (Set Digital Low Pass Filter to ~43Hz)
    Wire.endTransmission(); //End the transmission with the gyro
  }


user3917: As no preview is available at the given links (for YMFC-AL_setup.ino and YMFC-AL_Flight_controller.ino at drive.google.com) and I don't want to download the code to my system, I haven't looked at the whole program; however, from the code included in the question, it's clear that it uses direct IO rather than Arduino API IO.
Direct IO expressions like PINB & B00000001 [see Edit 1, Note 1] affect differently-numbered digital pins on the Mega than on the Uno or Nano.  (Or, more generally, on boards based on ATmega256x vs ATmega328x or 168x vs ATmega32U4 or 16U4.)
On the Arduino Nano and Uno, PB0–PB5 are assigned to Arduino digital pins 8–13.
On the Arduino Micro with 32U4, PB0–PB3 are not assigned to Arduino digital pins; they connect to SS, SCK, MOSI, MISO, while PB4–PB7 are assigned to Arduino digital pins 8–11.
On the Arduino Mega2560 with  ATmega2560,  PB0–PB3 are assigned to Arduino digital pins 53, 52, 51, 50 respectively, and PB4–PB7 are assigned to 10–13.
Summary:  To adapt direct IO code written for an Uno to a Mega, you may need to change ports and pins numbers.  Just moving wires around to corresponding pins may or may not fix problems; if the code uses a mix of direct IO and API IO (with digitalWrite() etc.) the code may need to be changed as well.  For example, in setup() it might use API pin identifiers, and in ISRs might use direct IO, an approach that will malfunction when transferring code to a differently-mapped board.
Note, see numerous excellent pinout diagrams at pighixxx.com.
Edit 1: 
Note 1:  In a file called binary.h, the Arduino IDE's programming environment defines a set of 510 constants whose names consist of a B followed by from 1 to 8 zeroes and ones, with values equal to corresponding binary numbers.  The value of the expression PINB & B00000001 is equal to the low-order bit (PB0) of input register PINB.    The value of PINB & B00001000 is 8 (ie, 1<<3) if PB3 is high, and is 0 if PB3 is low.  Typically, these binary constants are used as bit masks for bit operations (AND &, OR |, XOR ^).
Note 2:  When including code in a stackexchange question or answer, first paste the code into the question or answer editing box; then in that editing box, highlight the code and press ctrl-k.  (Alternately, highlight the code and click the {} icon in the toolbar at the top of the editing box.)
Rather large sections of code can be pasted into questions and answers.  Generally, paste in at least enough to be compilable and exhibit the problem.  If any variable or procedure definitions, #include lines, etc., are left out, people may have to play guessing games to answer the question, and that's generally undesirable as it wastes time and does not elicit good answers.

31093: <p>The code below was taken online and was written for the Arduino Uno. I know C++ however I am a beginner with Arduino so I don't understand this compatibility issue or how to fix it. I am very thankful for any help. Here is part of the code - the variable declarations: (I can upload the entire code if that would be more helpful).</p>

<pre class="lang-cpp prettyprint-override"><code>ISR(PCINT0_vect) {
  current_time = micros();
  //Channel 1=========================================
  if(PINB &amp; B00000001) { //Is input 8 high?
    if(last_channel_1 == 0) { //Input 8 changed from 0 to 1.
      last_channel_1 = 1; //Remember current input state.
      timer_1 = current_time; //Set timer_1 to current_time.
    }
  } else if(last_channel_1 == 1) { //Input 8 is not high and changed from 1 to 0.
    last_channel_1 = 0; //Remember current input state.
    receiver_input[1] = current_time - timer_1; //Channel 1 is current_time - timer_1.
  }
  //Channel 2=========================================
  if(PINB &amp; B00000010 ) { //Is input 9 high?
    if(last_channel_2 == 0) { //Input 9 changed from 0 to 1.
      last_channel_2 = 1; //Remember current input state.
      timer_2 = current_time; //Set timer_2 to current_time.
    }
  } else if(last_channel_2 == 1) { //Input 9 is not high and changed from 1 to 0.
    last_channel_2 = 0; //Remember current input state.
    receiver_input[2] = current_time - timer_2; //Channel 2 is current_time - timer_2.
  }
  //Channel 3=========================================
  if(PINB &amp; B00000100 ) { //Is input 10 high?
    if(last_channel_3 == 0) { //Input 10 changed from 0 to 1.
      last_channel_3 = 1; //Remember current input state.
      timer_3 = current_time; //Set timer_3 to current_time.
    }
  } else if(last_channel_3 == 1) { //Input 10 is not high and changed from 1 to 0.
    last_channel_3 = 0; //Remember current input state.
    receiver_input[3] = current_time - timer_3; //Channel 3 is current_time - timer_3.
  }
  //Channel 4=========================================
  if(PINB &amp; B00001000 ) { //Is input 11 high?
    if(last_channel_4 == 0) { //Input 11 changed from 0 to 1.
      last_channel_4 = 1; //Remember current input state.
      timer_4 = current_time; //Set timer_4 to current_time.
    }
  } else if(last_channel_4 == 1) { //Input 11 is not high and changed from 1 to 0.
    last_channel_4 = 0; //Remember current input state.
    receiver_input[4] = current_time - timer_4; //Channel 4 is current_time - timer_4.
  }
}

void set_gyro_registers() {
  //Set up the MPU-6050
  if(eeprom_data[31] == 1) {
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search.
    Wire.write(0x6B); //We want to write to the PWR_MGMT_1 register (6B hex)
    Wire.write(0x00); //Set the register bits as 00000000 to activate the gyro
    Wire.endTransmission(); //End the transmission with the gyro.
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search.
    Wire.write(0x1B); //We want to write to the GYRO_CONFIG register (1B hex)
    Wire.write(0x08); //Set the register bits as 00001000 (500dps full scale)
    Wire.endTransmission(); //End the transmission with the gyro
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search.
    Wire.write(0x1C); //We want to write to the ACCEL_CONFIG register (1A hex)
    Wire.write(0x10); //Set the register bits as 00010000 (+/- 8g full scale range)
    Wire.endTransmission(); //End the transmission with the gyro
    //Let's perform a random register check to see if the values are written correct
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search
    Wire.write(0x1B); //Start reading @ register 0x1B
    Wire.endTransmission(); //End the transmission
    Wire.requestFrom(gyro_address, 1); //Request 1 bytes from the gyro
    while(Wire.available() &lt; 1); //Wait until the 6 bytes are received
    if(Wire.read() != 0x08) { //Check if the value is 0x08
      digitalWrite(12,HIGH); //Turn on the warning led
      while(1)delay(10); //Stay in this loop for ever
    }
    Wire.beginTransmission(gyro_address); //Start communication with the address found during search
    Wire.write(0x1A); //We want to write to the CONFIG register (1A hex)
    Wire.write(0x03); //Set the register bits as 00000011 (Set Digital Low Pass Filter to ~43Hz)
    Wire.endTransmission(); //End the transmission with the gyro
  }
</code></pre>
 3917: <p>As no preview is available at the given links (for <a href="https://drive.google.com/file/d/0B5tJTKkHim16NFZUenB6elZEbDA/view" rel="nofollow noreferrer">YMFC-AL_setup.ino</a> and <a href="https://drive.google.com/file/d/0B5tJTKkHim16VDFhdHhNUDVOcTA/view" rel="nofollow noreferrer">YMFC-AL_Flight_controller.ino</a> at drive.google.com) and I don't want to download the code to my system, I haven't looked at the whole program; however, from the code included in the question, it's clear that it uses direct IO rather than Arduino API IO.</p>

<p>Direct IO expressions like <code>PINB &amp; B00000001</code> [see Edit 1, Note 1] affect differently-numbered digital pins on the Mega than on the Uno or Nano.  (Or, more generally, on boards based on ATmega256x vs ATmega328x or 168x vs ATmega32U4 or 16U4.)</p>

<p>On the Arduino Nano and Uno, PB0–PB5 are assigned to Arduino digital pins 8–13.</p>

<p>On the Arduino Micro with 32U4, PB0–PB3 are not assigned to Arduino digital pins; they connect to SS, SCK, MOSI, MISO, while PB4–PB7 are assigned to Arduino digital pins 8–11.</p>

<p>On the Arduino Mega2560 with  ATmega2560,  PB0–PB3 are assigned to Arduino digital pins 53, 52, 51, 50 respectively, and PB4–PB7 are assigned to 10–13.</p>

<p>Summary:  To adapt direct IO code written for an Uno to a Mega, you may need to change ports and pins numbers.  Just moving wires around to corresponding pins may or may not fix problems; if the code uses a mix of direct IO and API IO (with <code>digitalWrite()</code> etc.) the code may need to be changed as well.  For example, in <code>setup()</code> it might use API pin identifiers, and in ISRs might use direct IO, an approach that will malfunction when transferring code to a differently-mapped board.</p>

<p>Note, see <a href="http://www.pighixxx.com/test/pinoutspg/" rel="nofollow noreferrer">numerous excellent pinout diagrams</a> at pighixxx.com.</p>

<p><em>Edit 1:</em> </p>

<p>Note 1:  In a file called <code>binary.h</code>, the Arduino IDE's programming environment defines a set of 510 constants whose names consist of a <code>B</code> followed by from 1 to 8 zeroes and ones, with values equal to corresponding binary numbers.  The value of the expression <code>PINB &amp; B00000001</code> is equal to the low-order bit (PB0) of input register PINB.    The value of <code>PINB &amp; B00001000</code> is 8 (ie, 1&lt;&lt;3) if PB3 is high, and is 0 if PB3 is low.  Typically, these binary constants are used as <em>bit masks</em> for bit operations (AND &amp;, OR |, XOR ^).</p>

<p>Note 2:  When including code in a stackexchange question or answer, first paste the code into the question or answer editing box; then in that editing box, highlight the code and press ctrl-k.  (Alternately, highlight the code and click the <code>{}</code> icon in the toolbar at the top of the editing box.)</p>

<p>Rather large sections of code can be pasted into questions and answers.  Generally, paste in at least enough to be compilable and exhibit the problem.  If any variable or procedure definitions, <code>#include</code> lines, etc., are left out, people may have to play guessing games to answer the question, and that's generally undesirable as it wastes time and does not elicit good answers.</p>
