Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Commit 992b10e

Browse files
committed
Add PWM function to DigitalPin.
1 parent a9ff04b commit 992b10e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

robot-control-src/DigitalPin.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class DigitalPin: public GpioInterface {
2121
{
2222
writeS(value);
2323
}
24+
void setDutyCycle(const int dutyCycle) const
25+
{
26+
setDutyCycleS(dutyCycle);
27+
}
2428
static int readS()
2529
{
2630
return digitalRead(pin);
@@ -33,6 +37,10 @@ class DigitalPin: public GpioInterface {
3337
{
3438
digitalWrite(pin, value);
3539
}
40+
static void setDutyCycleS(const int dutyCycle)
41+
{
42+
analogWrite(pin, dutyCycle);
43+
}
3644
};
3745

3846
template<std::uint8_t PIN>

0 commit comments

Comments
 (0)