new Version added

This commit is contained in:
Fatima Idrees 2025-05-28 09:02:46 +03:00
parent 70868e049c
commit e9bedf8c5e
4 changed files with 43 additions and 0 deletions

View File

@ -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!

34
FanMotorV2.ubl Normal file
View File

@ -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
}
}
}

BIN
Images/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

BIN
Images/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB