Uploading

This commit is contained in:
Fatima Idrees 2025-06-03 14:02:19 +03:00
parent 26bd63e232
commit f40675acb1
12 changed files with 218 additions and 1 deletions

63
Spark_MDP/README.md Normal file
View File

@ -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 dont 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 microcontrollers pins (see your boards 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!*

58
Spark_MDP/Spark_MDP.ubl Normal file
View File

@ -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

View File

@ -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.
![](Images/1.png)
*Example 1*
This function takes three values, one for each color: Red, Green, and Blue.
![](Images/2.png)
*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

View File

@ -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.
![](Images/1.png)
*Example 1*
This function takes three values, one for each color: Red, Yellow, and Green.
![](Images/2.png)
*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

View File

@ -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.
![](../Spark_Ultrasonic/)
*Example*
This function reads values from the pin and can be used inside an if-statement or assigned as a value.

View File

@ -3,7 +3,7 @@ Displaying the version and its functions with examples.
## Version 01
In these functions, you must specify the I2C pin corresponding to the module you are using.
In these functions, you must specify the PWM pin corresponding to the module you are using.
![](Images/1.png)

53
Spark_PWM/Spark_PWM.ubp Normal file
View File

@ -0,0 +1,53 @@
module main
author unknown
version 1 0
description ''
spec ' ' 'Fan Motor' 'Fan Motor Pin _ to Turn Off' 'num' 17
spec ' ' 'Fan Motor Pin' 'Fan Motor Pin _ Direction _ Speed _' 'num bool auto' 17 true 50
to 'Fan Motor' Pin {
digitalWriteOp (Pin + 1) false
digitalWriteOp (Pin + 2) false
}
to 'Fan Motor Pin' Pin Direction Speed {
if (and (Speed > 0) (Speed <= 100)) {
local 'PWM' (absoluteValue (((Speed - 1) * ((1023 - 1) / 99)) + 1))
if (Direction == (booleanConstant false)) {
if (and (PWM > 0) (PWM < 1024)) {
digitalWriteOp (Pin + 1) true
analogWriteOp (Pin + 2) (1023 - PWM)
}
} else {
if (and (PWM > 0) (PWM < 1024)) {
digitalWriteOp (Pin + 1) false
analogWriteOp (Pin + 2) PWM
}
}
}
}
script 50 168 {
to 'Fan Motor' {}
}
script 66 341 {
to 'Fan Motor Pin' {}
}
module Spark_PWM Control
author 'Fab Lab'
version 1 0
description ''
spec ' ' 'FanMotor' 'FanMotor Pin _ Direction _ Speed _' 'num bool num' 17 true 50
spec ' ' 'FanMotor2' 'FanMotor Pin _ to Turn Off' 'auto' 18
to FanMotor Pin Direction Speed {
}
to FanMotor2 Pin {
}