Skip to main content


Returns the step-count of a pin in PWM mode




Integer — the PWM step-count


This method provides the actual number of Pulse-Width Modulation steps that have been configured in hardware. Like pin.getperiod(), this may not be exactly the value specified in pin.configure(), due to rounding and/or whether the pin was configured as PWM_OUT, which gives priority to providing the period accurately, or PWM_OUT_STEPS, which gives priority to providing an accurate number of steps. Either option is a trade-off.

An exception with the error message the index 'getsteps' does not exist will be thrown if the call is made to a pin that does not support PWM. If the pin does support PWM, but has been configured to another function, this method returns 0.

pin.getsteps() provides the number of steps even if the PWM is running in ‘zombie’ mode, ie. it continues to operate across Squirrel reloads, firmware upgrades and device restarts.