Spark_FanMotor/FanMotorV2.ubl
2025-05-28 09:02:46 +03:00

35 lines
929 B
Plaintext

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