Uploading
This commit is contained in:
1 parent
26bd63e232
commit
f40675acb1
12 files changed
+218
-1
No files matched your search
@@ -0,0 +1,63 @@
|
||||
# Multiple Digital Pins Library for MicroBlocks
|
||||
|
||||
Welcome to the **MDP Library** for MicroBlocks!
|
||||
This library makes it easy for anyone—even if you don’t know how to code or use a computer much—to control these modules: **RGB LED, Traffic Light,** and **Ultrasonic** using simple blocks in MicroBlocks.
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
- **Easy Drag-and-Drop Blocks** for controlling the module.
|
||||
- **No Coding Required**.
|
||||
- **Beginner-Friendly Instructions**.
|
||||
- **Control the MDP Modules Easily**.
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
|
||||
**What you need:**
|
||||
- Spark microcontroller and connecting wires.
|
||||
- MicroBlocks IDE installed ([Download here](https://microblocks.fun/download/)).
|
||||
- MDP Modules and basic connecting wires.
|
||||
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
1. **Download the MDP Library:**
|
||||
Download the library file from [here](../Spark_MDP.ubl).
|
||||
|
||||
2. **Open MicroBlocks IDE** on your computer.
|
||||
|
||||
3. **Add the Library:**
|
||||
- Go to the library manager in MicroBlocks.
|
||||
- Click “Import Library” or drag and drop the downloaded file into the IDE.
|
||||
|
||||
---
|
||||
|
||||
## How to Use
|
||||
|
||||
1. **Connect your module** to your microcontroller’s pins (see your board’s pinout for details).
|
||||
|
||||
2. **Open MicroBlocks IDE** and make sure your board is connected.
|
||||
|
||||
3. **Find the MDP blocks** in the blocks menu.
|
||||
|
||||
4. **Drag the blocks** you want to use into your script area.
|
||||
|
||||
5. **Click the green flag** or “Run” to start controlling the module!
|
||||
|
||||
---
|
||||
## Examples
|
||||
|
||||
There is special examples for each module:
|
||||
|
||||
- [**RGBLED**](../Spark_MDP/Spark_RGBLED/README.md)
|
||||
- [**Traffic Light**](../Spark_MDP/Spark_TrafficLight/README.md)
|
||||
- [**LEUltrasonicD**](../Spark_MDP/Spark_Ultrasonic/README.md)
|
||||
|
||||
---
|
||||
|
||||
*Have fun building with Spark Kit!*
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
module Spark_MDP 'cat;Variables'
|
||||
author 'Fab Lab BH'
|
||||
version 1 0
|
||||
description ''
|
||||
|
||||
spec ' ' 'RGBLED3' 'RGBLED Pin _ R _ G _ B _' 'num num num auto' 17 50 50 50
|
||||
spec ' ' 'RGBLED3 Pin' 'RGBLED Pin _ R _ G _ B _' 'auto bool bool bool' 17 true true true
|
||||
spec ' ' 'Traffic Light' 'Traffic Light Pin _ R _ Y _ G _' 'auto bool bool bool' 17 true true true
|
||||
spec ' ' 'Traffic Light Pin' 'Traffic Light Pin _ R _ Y _ G _' 'num num num num' 17 255 255 255
|
||||
spec 'r' 'Ultrasonic Pin' 'Ultrasonic Pin _' 'num' 17
|
||||
|
||||
to RGBLED3 Pin Red Green Blue {
|
||||
analogWriteOp Pin Red
|
||||
analogWriteOp (Pin + 1) Green
|
||||
analogWriteOp (Pin + 2) Blue
|
||||
}
|
||||
|
||||
to 'RGBLED3 Pin' Pin Red Green Blue {
|
||||
digitalWriteOp Pin Red
|
||||
digitalWriteOp (Pin + 1) Green
|
||||
digitalWriteOp (Pin + 2) Blue
|
||||
}
|
||||
|
||||
to 'Traffic Light' Pin Red Yellow Green {
|
||||
digitalWriteOp Pin Red
|
||||
digitalWriteOp (Pin + 1) Yellow
|
||||
digitalWriteOp (Pin + 2) Green
|
||||
}
|
||||
|
||||
to 'Traffic Light Pin' Pin Red Yellow Green {
|
||||
analogWriteOp Pin Red
|
||||
analogWriteOp (Pin + 1) Yellow
|
||||
analogWriteOp (Pin + 2) Green
|
||||
}
|
||||
|
||||
to 'Ultrasonic Pin' Pin {
|
||||
comment 'Contributed by Joan Guillén and Josep Ferràndiz'
|
||||
digitalWriteOp (Pin + 1) false
|
||||
waitMicros 2
|
||||
digitalWriteOp (Pin + 1) true
|
||||
waitMicros 50
|
||||
digitalWriteOp (Pin + 1) false
|
||||
local 'start' (microsOp)
|
||||
waitUntil (or (not (digitalReadOp (Pin + 2))) (((microsOp) - start) > 23320))
|
||||
waitUntil (or (digitalReadOp (Pin + 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 (Pin + 2))) (((microsOp) - start) > 23320))
|
||||
_sr04_last = ((10 * ((microsOp) - start)) / 583)
|
||||
comment 'Leave some time for reverberations to die away.'
|
||||
waitMillis 10
|
||||
return _sr04_last
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 73 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
@@ -0,0 +1,16 @@
|
||||
# RGB LED Versions
|
||||
Displaying the version and its functions with examples.
|
||||
|
||||
## Version 01
|
||||
|
||||
In these functions, you must specify the digital pin corresponding to the module you are using.
|
||||
|
||||

|
||||
|
||||
*Example 1*
|
||||
This function takes three values, one for each color: Red, Green, and Blue.
|
||||
|
||||

|
||||
|
||||
*Example 2*
|
||||
This function takes three values—one for Red, Green, and Blue—and also allows you to control the brightness of each.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
@@ -0,0 +1,16 @@
|
||||
# Traffic Light Versions
|
||||
Displaying the version and its functions with examples.
|
||||
|
||||
## Version 01
|
||||
|
||||
In these functions, you must specify the digital pin corresponding to the module you are using.
|
||||
|
||||

|
||||
|
||||
*Example 1*
|
||||
This function takes three values, one for each color: Red, Yellow, and Green.
|
||||
|
||||

|
||||
|
||||
*Example 2*
|
||||
This function takes three values—one for Red, Yellow, and Green—and also allows you to control the brightness of each.
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 120 KiB |
@@ -0,0 +1,11 @@
|
||||
# Ultrasonic Versions
|
||||
Displaying the version and its functions with examples.
|
||||
|
||||
## Version 01
|
||||
|
||||
In this function, you must specify the MDP pin corresponding to the module you are using.
|
||||
|
||||

|
||||
|
||||
*Example*
|
||||
This function reads values from the pin and can be used inside an if-statement or assigned as a value.
|
||||
Reference in new issue
Block a user