Controlling more fans with RAMPS board
From the sources of Marlin you can find how may fans you can use, even if you're not a coder it should be doable. From there you can find how to set the pins for the fans, provided that there are free unused and exposed (so that you do not have so solder directly to the microprocessor). First find how many fans are possible.

Starting in Marlin_main.cpp and searching for 106 (or 106 on the Marlin GitHub website) will lead you to the sources of the execution of the M106 command. Below a snippet of M106 and M107 is shown. The reason for M107 to be there becomes clear later.


#if FAN_COUNT &gt; 0

  /**
   * M106: Set Fan Speed
   *
   *  S&lt;int&gt;   Speed between 0-255
   *  P&lt;index&gt; Fan index, if more than one fan
   *
   * With EXTRA_FAN_SPEED enabled:
   *
   *  T&lt;int&gt;   Restore/Use/Set Temporary Speed:
   *           1     = Restore previous speed after T2
   *           2     = Use temporary speed set with T3-255
   *           3-255 = Set the speed for use with T2
   */
  inline void gcode_M106() {
    const uint8_t p = parser.byteval('P');
    if (p &lt; FAN_COUNT) {
      #if ENABLED(EXTRA_FAN_SPEED)
        const int16_t t = parser.intval('T');
        if (t &gt; 0) {
          switch (t) {
            case 1:
              fanSpeeds[p] = old_fanSpeeds[p];
              break;
            case 2:
              old_fanSpeeds[p] = fanSpeeds[p];
              fanSpeeds[p] = new_fanSpeeds[p];
              break;
            default:
              new_fanSpeeds[p] = MIN(t, 255);
              break;
          }
          return;
        }
      #endif // EXTRA_FAN_SPEED
      const uint16_t s = parser.ushortval('S', 255);
      fanSpeeds[p] = MIN(s, 255U);
    }
  }

  /**
   * M107: Fan Off
   */
  inline void gcode_M107() {
    const uint16_t p = parser.ushortval('P');
    if (p &lt; FAN_COUNT) fanSpeeds[p] = 0;
  }

#endif // FAN_COUNT &gt; 0


Looking at this code, the first thing (actually the first line, #if FAN_COUNT &gt; 0, already hints to that) that catches your attention is constant FAN_COUNT. Apparently the software knows how much fans are defined! Interesting! How does it know that! This piece of code ends just after handling the M107 command (line #endif // FAN_COUNT &gt; 0), hence it is displayed here.

Continuing the search by finding how FAN_COUNT is set (using the search on GitHub for the Marlin repository) leads to file Conditionals_post.h. An interesting part is:


/**
 * Up to 3 PWM fans
 */
#if HAS_FAN2
  #define FAN_COUNT 3
#elif HAS_FAN1
  #define FAN_COUNT 2
#elif HAS_FAN0
  #define FAN_COUNT 1
#else
  #define FAN_COUNT 0
#endif


So depending on HAS_FANx (where x denotes 0, 1 or 2) you can have multiple fans, up to 3 in total! Cool, learned something in the process. :)

Let's now search for HAS_FANx; in the same file you will find:


// Other fans
#define HAS_FAN0 (PIN_EXISTS(FAN))
#define HAS_FAN1 (PIN_EXISTS(FAN1) && CONTROLLER_FAN_PIN != FAN1_PIN && E0_AUTO_FAN_PIN != FAN1_PIN && E1_AUTO_FAN_PIN != FAN1_PIN && E2_AUTO_FAN_PIN != FAN1_PIN && E3_AUTO_FAN_PIN != FAN1_PIN)
#define HAS_FAN2 (PIN_EXISTS(FAN2) && CONTROLLER_FAN_PIN != FAN2_PIN && E0_AUTO_FAN_PIN != FAN2_PIN && E1_AUTO_FAN_PIN != FAN2_PIN && E2_AUTO_FAN_PIN != FAN2_PIN && E3_AUTO_FAN_PIN != FAN2_PIN)


Now we are getting into clear water! This codes hints to FAN1_PIN and FAN2_PIN. If you look into you pin layout file, e.g. pins_RAMPS.h you see that that are the pin constants that need to be defined, actually FAN1_PIN is e.g. set if you choose an "EFF" configuration (Hotend, Fan0, Fan1), e.g. #define FAN1_PIN  RAMPS_D8_PIN.

What is left for you to do is find an unused pin of your micro-controller and set the FAN2_PIN with #define FAN2_PIN  &lt;a free pin number&gt;.

E.g. pin 4 is not a used pin number (and an analog output pin). Don't forget that the pin you choose cannot directly run a fan, it should be used to schedule a MOSFET.

Note that a dual external fan header "Reprap Ramps1.4 RRD Fan Extender" exists, this describes using the D6 and D11 pins. Further investigation led to a 3D.SE posting using this fan header: "How to configure Marlin to enable auto-fans with dual extruder".