---
tag: m0106
title: Set Fan Speed
brief: Turn on the fan and set its speed
author: thinkyhead

group: thermal
requires: EXTRA_FAN_SPEED

codes: [ M106 ]

notes:
  - '[`M106`](/docs/gcode/M106.html) with no speed sets the fan to full speed.'
  - Turn off fans with [`M107`](/docs/gcode/M107.html).

parameters:
  -
    tag: I
    since: 2.0.6
    optional: true
    description: Material preset index. Overrides `S`.
    values:
      -
        type: int
        tag: index
  -
    tag: S
    optional: true
    description: Speed, from 0 to 255. S255 provides 100% duty cycle; S128 produces 50%.
    values:
      -
        tag: speed
        type: byte
  -
    tag: P
    optional: true
    description: Fan index
    values:
      -
        tag: index
        type: int
  -
    tag: T
    optional: true
    description: |
      Secondary speed. Added in Marlin 1.1.7. (Requires `EXTRA_FAN_SPEED`)
      - `M106 P<fan> T3-255` sets a secondary speed for `<fan>`.
      - `M106 P<fan> T2` uses the set secondary speed.
      - `M106 P<fan> T1` restores the previous fan speed.
    values:
      -
        tag: secondary
        type: int

example:
  -
    pre: Turn on the fan at 200/255 DC
    code: M106 S200

---

Turn on one of the fans and set its speed. If no fan index is given, the print cooling fan is selected. The fan speed applies to the next block added to the planner, so it will not take effect until previous moves in the planner are done. Under manual control with an idle machine, [`M106`](/docs/gcode/M106.html) will change the fan speed immediately.
