Uploading
This commit is contained in:
parent
c430bc663d
commit
09232ad2bf
@ -1,6 +1,6 @@
|
|||||||
module Spark_MultiDigitalPins 'cat;Variables'
|
module Spark_MultiDigitalPins Variables
|
||||||
author 'Fatima Idrees'
|
author 'Fatima Idrees'
|
||||||
version 1 0
|
version 1 1
|
||||||
description ''
|
description ''
|
||||||
|
|
||||||
spec ' ' 'RGBLED' 'RGBLED Pin _ R _ G _ B _' 'auto bool bool bool' 17 false false false
|
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
|
spec 'r' 'Ultransonic Pin' 'Ultransonic Pin _' 'num' 17
|
||||||
|
|
||||||
to RGBLED Pin Red Green Blue {
|
to RGBLED Pin Red Green Blue {
|
||||||
|
comment 'Created by Fatima Idrees'
|
||||||
digitalWriteOp Pin Red
|
digitalWriteOp Pin Red
|
||||||
Pin += 1
|
digitalWriteOp (Pin + 1) Green
|
||||||
digitalWriteOp Pin Green
|
digitalWriteOp (Pin + 2) Blue
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin Blue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to RGBLED2 Pin Red Green Blue {
|
to RGBLED2 Pin Red Green Blue {
|
||||||
|
comment 'Created by Fatima Idrees'
|
||||||
analogWriteOp Pin Red
|
analogWriteOp Pin Red
|
||||||
Pin += 1
|
analogWriteOp (Pin + 1) Green
|
||||||
analogWriteOp Pin Green
|
analogWriteOp (Pin + 2) Blue
|
||||||
Pin += 1
|
|
||||||
analogWriteOp Pin Blue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to 'Ultransonic Pin' Input {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user