## Input/Output

### setADCSampleTime()

The function `setADCSampleTime(duration)`

is used to change the default sample time for `analogRead()`

.

On the Photon, P1, Electron, and E Series this parameter can be one of the following values (ADC clock = 30MHz or 33.3ns per cycle):

- ADC_SampleTime_3Cycles: Sample time equal to 3 cycles, 100ns
- ADC_SampleTime_15Cycles: Sample time equal to 15 cycles, 500ns
- ADC_SampleTime_28Cycles: Sample time equal to 28 cycles, 933ns
- ADC_SampleTime_56Cycles: Sample time equal to 56 cycles, 1.87us
- ADC_SampleTime_84Cycles: Sample time equal to 84 cycles, 2.80us
- ADC_SampleTime_112Cycles: Sample time equal to 112 cycles, 3.73us
- ADC_SampleTime_144Cycles: Sample time equal to 144 cycles, 4.80us
- ADC_SampleTime_480Cycles: Sample time equal to 480 cycles, 16.0us (default)

The default is ADC_SampleTime_480Cycles. This means that the ADC is sampled for 16 us which can provide a more accurate reading, at the expense of taking longer than using a shorter ADC sample time. If you are measuring a high frequency signal, such as audio, you will almost certainly want to reduce the ADC sample time.

Furthermore, 5 consecutive samples at the sample time are averaged in analogRead(), so the time to convert is closer to 80 us, not 16 us, at 480 cycles.

Note:

setADCSampleTime is not supported on the P2, Photon 2, or Gen 3 devices (Argon, Boron, B Series SoM, Tracker SoM).