Skip to content

# File evamPwmDriver.h

File List > src > evamPwmDriver.h

Go to the documentation of this file

    #pragma once

    #include <Arduino.h>

    namespace evam
    {
        template <int kPin>
        class PwmDriver
        {
        public:
            PwmDriver()
            {
                pinMode(kPin, OUTPUT);
                actUnipolar(0);
            }

        protected:
            void actUnipolar(unsigned short aValue)
            {
                int pwm = map(constrain(aValue, 0, 1000), 0, 1000, 0, 255);
                analogWrite(kPin, pwm);
            }
        };

    } // namespace evam