new Version added
This commit is contained in:
parent
70868e049c
commit
e9bedf8c5e
@ -28,7 +28,16 @@ The function now converts the percentage to a value between 0 and 1023 using PWM
|
||||
|
||||
---
|
||||
|
||||
## Version 04:
|
||||
|
||||

|
||||
|
||||
The previous function, updated to incorporate direction.
|
||||
|
||||
---
|
||||
|
||||
## Usage Example:
|
||||

|
||||

|
||||
|
||||
A way to test the Library!
|
||||
|
34
FanMotorV2.ubl
Normal file
34
FanMotorV2.ubl
Normal 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
BIN
Images/6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 131 KiB |
BIN
Images/7.png
Normal file
BIN
Images/7.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
x
Reference in New Issue
Block a user