diff --git a/Documentation/README.md b/Documentation/README.md index a692e65..85e943e 100644 --- a/Documentation/README.md +++ b/Documentation/README.md @@ -28,7 +28,16 @@ The function now converts the percentage to a value between 0 and 1023 using PWM --- +## Version 04: + +![](../Images/6.png) + +The previous function, updated to incorporate direction. + +--- + ## Usage Example: ![](../Images/5.png) +![](../Images/7.png) A way to test the Library! diff --git a/FanMotorV2.ubl b/FanMotorV2.ubl new file mode 100644 index 0000000..1a48a65 --- /dev/null +++ b/FanMotorV2.ubl @@ -0,0 +1,34 @@ +module FanMotorV2 +author unknown +version 1 0 +description '' +variables PWM + + spec ' ' 'Fan Motor Pin' 'Fan Motor Pin _ State _ Speed _' 'num bool num' 23 true 50 + spec ' ' 'Fan Motor' 'Fan Motor Pin _ Direction _ Speed _' 'num bool num' 18 true 50 + +to 'Fan Motor' Pin Direction Speed { + if (and (Speed > 0) (Speed <= 100)) { + PWM = (absoluteValue (((Speed - 1) * ((1023 - 1) / 99)) + 1)) + if (Direction == (booleanConstant false)) { + if (and (PWM > 0) (PWM < 1024)) {analogWriteOp Pin PWM} + } else { + Pin += 1 + if (and (PWM > 0) (PWM < 1024)) { + analogWriteOp Pin PWM + } + } + } +} + +to 'Fan Motor Pin' Pin State Speed { + if (and (Speed > 0) (Speed <= 100)) { + PWM = (absoluteValue (((Speed - 1) * ((1023 - 1) / 99)) + 1)) + if (State == (booleanConstant true)) { + if (and (PWM > 0) (PWM < 1024)) {analogWriteOp Pin PWM} + } else { + digitalWriteOp Pin false + } + } +} + diff --git a/Images/6.png b/Images/6.png new file mode 100644 index 0000000..8571092 Binary files /dev/null and b/Images/6.png differ diff --git a/Images/7.png b/Images/7.png new file mode 100644 index 0000000..6ed23b5 Binary files /dev/null and b/Images/7.png differ