New Upload
This commit is contained in:
parent
d4f5cdcd2d
commit
4363207b62
BIN
Images/7.png
Normal file
BIN
Images/7.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 113 KiB |
BIN
Images/8.png
Normal file
BIN
Images/8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
@ -26,7 +26,7 @@ This library makes it easy for anyone—even if you don’t know how to code or
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. **Download the Fan Motor Library:**
|
1. **Download the Fan Motor Library:**
|
||||||
Download the library file from [here](RGB_LED.ubl).
|
Download the library file from [here](Spark_MultiDigitalPins.ubl).
|
||||||
|
|
||||||
2. **Open MicroBlocks IDE** on your computer.
|
2. **Open MicroBlocks IDE** on your computer.
|
||||||
|
|
||||||
|
63
RGB_LED.ubl
63
RGB_LED.ubl
@ -1,63 +0,0 @@
|
|||||||
module RGB_LED
|
|
||||||
author unknown
|
|
||||||
version 1 0
|
|
||||||
description ''
|
|
||||||
variables SetPins
|
|
||||||
|
|
||||||
spec ' ' 'RGBLED' 'RGB Pin _ R _ G _ B _' 'auto bool bool bool' 17 false false false
|
|
||||||
spec ' ' 'PickColor' 'RGB Pin _ Color _' 'num str' 17 'Empty'
|
|
||||||
|
|
||||||
to PickColor Pin Color {
|
|
||||||
if (Color == ('[data:toString]' 'Red')) {
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
} (Color == ('[data:toString]' 'Yellow')) {
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
} (Color == ('[data:toString]' 'Green')) {
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
} (Color == ('[data:toString]' 'Purple')) {
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
} (Color == ('[data:toString]' 'Blue')) {
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
} true {
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin true
|
|
||||||
} else {
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
to RGBLED Pin Red Green Blue {
|
|
||||||
digitalWriteOp Pin Red
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin Green
|
|
||||||
Pin += 1
|
|
||||||
digitalWriteOp Pin Blue
|
|
||||||
}
|
|
||||||
|
|
46
Spark_MultiDigitalPins.ubl
Normal file
46
Spark_MultiDigitalPins.ubl
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
module Spark_MultiDigitalPins Variables
|
||||||
|
author 'Fatima Idrees'
|
||||||
|
version 1 1
|
||||||
|
description ''
|
||||||
|
|
||||||
|
spec ' ' 'RGBLED' 'RGBLED Pin _ R _ G _ B _' 'auto bool bool bool' 17 false false false
|
||||||
|
spec ' ' 'RGBLED2' 'RGBLED Pin _ R _ G _ B _' 'auto auto auto auto' 17 50 50 50
|
||||||
|
spec 'r' 'Ultransonic Pin' 'Ultransonic Pin _' 'num' 17
|
||||||
|
|
||||||
|
to RGBLED Pin Red Green Blue {
|
||||||
|
comment 'Created by Fatima Idrees'
|
||||||
|
digitalWriteOp Pin Red
|
||||||
|
digitalWriteOp (Pin + 1) Green
|
||||||
|
digitalWriteOp (Pin + 2) Blue
|
||||||
|
}
|
||||||
|
|
||||||
|
to RGBLED2 Pin Red Green Blue {
|
||||||
|
comment 'Created by Fatima Idrees'
|
||||||
|
analogWriteOp Pin Red
|
||||||
|
analogWriteOp (Pin + 1) Green
|
||||||
|
analogWriteOp (Pin + 2) Blue
|
||||||
|
}
|
||||||
|
|
||||||
|
to 'Ultransonic Pin' Input {
|
||||||
|
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