Spark_Library/Spark_I2C/Spark_I2C.ubp
2025-06-03 13:31:54 +03:00

64 lines
1.2 KiB
Plaintext

module main
author unknown
version 1 0
description ''
spec ' ' 'Motor Driver A' 'Motor Driver A State _ Direction _ Speed _' 'bool bool auto' false false 100
spec ' ' 'Motor Driver B' 'Motor Driver B State _ Direction _ Speed _' 'bool bool auto' false false 100
to 'Motor Driver A' State Direction Speed {
if (State == (booleanConstant true)) {
if (Direction == (booleanConstant false)) {
i2cSet 0 1 Speed
i2cSet 0 2 0
} else {
i2cSet 0 1 0
i2cSet 0 2 Speed
}
} else {
i2cSet 0 1 0
i2cSet 0 2 0
}
}
to 'Motor Driver B' State Direction Speed {
if (State == (booleanConstant true)) {
if (Direction == (booleanConstant false)) {
i2cSet 0 3 Speed
i2cSet 0 4 0
} else {
i2cSet 0 3 0
i2cSet 0 4 Speed
}
} else {
i2cSet 0 3 0
i2cSet 0 4 0
}
}
script 752 148 {
whenStarted
forever {
'Motor Driver A' false true 100
waitMillis 1000
'Motor Driver A' false false 50
waitMillis 1000
}
}
script 50 205 {
to 'Motor Driver B' {}
}
script 424 387 {
to 'Motor Driver A' {}
}
script 248 718 {
'Motor Driver B' true true 100
waitMillis 1000
'Motor Driver B' false false 100
waitMillis 1000
}