Uploading

This commit is contained in:
Fatima Idrees 2025-06-01 08:54:24 +03:00
parent c430bc663d
commit 09232ad2bf

View File

@ -1,6 +1,6 @@
module Spark_MultiDigitalPins 'cat;Variables'
module Spark_MultiDigitalPins Variables
author 'Fatima Idrees'
version 1 0
version 1 1
description ''
spec ' ' 'RGBLED' 'RGBLED Pin _ R _ G _ B _' 'auto bool bool bool' 17 false false false
@ -8,22 +8,39 @@ description ''
spec 'r' 'Ultransonic Pin' 'Ultransonic Pin _' 'num' 17
to RGBLED Pin Red Green Blue {
comment 'Created by Fatima Idrees'
digitalWriteOp Pin Red
Pin += 1
digitalWriteOp Pin Green
Pin += 1
digitalWriteOp Pin Blue
digitalWriteOp (Pin + 1) Green
digitalWriteOp (Pin + 2) Blue
}
to RGBLED2 Pin Red Green Blue {
comment 'Created by Fatima Idrees'
analogWriteOp Pin Red
Pin += 1
analogWriteOp Pin Green
Pin += 1
analogWriteOp Pin Blue
analogWriteOp (Pin + 1) Green
analogWriteOp (Pin + 2) Blue
}
to 'Ultransonic Pin' Input {
return ('distance (cm)' (Input + 1) (Input + 2))
comment 'Contributed by Joan Guillén and Josep Ferràndiz'
digitalWriteOp (Input + 1) false
waitMicros 2
digitalWriteOp (Input + 1) true
waitMicros 50
digitalWriteOp (Input + 1) false
local 'start' (microsOp)
waitUntil (or (not (digitalReadOp (Input + 2))) (((microsOp) - start) > 23320))
waitUntil (or (digitalReadOp (Input + 2)) (((microsOp) - start) > 23320))
if (((microsOp) - start) > 23320) {
comment 'Distance sensor not ready; return the last distance reading'
return _sr04_last
}
comment 'Pulse sent. Measure time until echo is detected.'
start = (microsOp)
waitUntil (or (not (digitalReadOp (Input + 2))) (((microsOp) - start) > 23320))
_sr04_last = ((10 * ((microsOp) - start)) / 583)
comment 'Leave some time for reverberations to die away.'
waitMillis 10
return _sr04_last
}