Adding new files

This commit is contained in:
Fatima Idrees 2025-06-03 13:31:54 +03:00
parent c66d9b8f9e
commit bd355c0912
5 changed files with 156 additions and 0 deletions

View File

@ -0,0 +1,21 @@
module Spark_Analog 'cat;Operators'
author 'Fab Lab BH'
version 1 0
description ''
spec 'r' 'Film Pressure Pin' 'Film Pressure Pin _' 'num' 39
spec 'r' 'PhotoResistance Pin' 'Photoresistance Pin _' 'num' 39
spec 'r' 'Potentiometer' 'Potentiometer Pin _' 'num' 39
to 'Film Pressure Pin' Pin {
return (analogReadOp Pin)
}
to 'PhotoResistance Pin' Pin {
return (analogReadOp Pin)
}
to Potentiometer Pin {
return (analogReadOp Pin)
}

61
Spark_I2C/README.md Normal file
View File

@ -0,0 +1,61 @@
# I2C Library for MicroBlocks
Welcome to the **I2C 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: **Motor Driver** using simple blocks in MicroBlocks.
---
## Features
- **Easy Drag-and-Drop Blocks** for controlling the module.
- **No Coding Required**.
- **Beginner-Friendly Instructions**.
- **Control the I2C Modules Easily**.
---
## Getting Started
**What you need:**
- Spark microcontroller and connecting wires.
- MicroBlocks IDE installed ([Download here](https://microblocks.fun/download/)).
- I2C Modules and basic connecting wires.
---
## Installation
1. **Download the I2C Library:**
Download the library file from [here](../Spark_I2C.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 I2C 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:
- [**Motor Driver**](../Spark_I2C/Spark_MotorDriver/README.md)
---
*Have fun building with Spark Kit!*

63
Spark_I2C/Spark_I2C.ubp Normal file
View File

@ -0,0 +1,63 @@
module main
author unknown
version 1 0
description ''
spec ' ' 'Motor Driver A' 'Motor Driver A State _ Direction _ Speed _' 'bool bool auto' false false 100
spec ' ' 'Motor Driver B' 'Motor Driver B State _ Direction _ Speed _' 'bool bool auto' false false 100
to 'Motor Driver A' State Direction Speed {
if (State == (booleanConstant true)) {
if (Direction == (booleanConstant false)) {
i2cSet 0 1 Speed
i2cSet 0 2 0
} else {
i2cSet 0 1 0
i2cSet 0 2 Speed
}
} else {
i2cSet 0 1 0
i2cSet 0 2 0
}
}
to 'Motor Driver B' State Direction Speed {
if (State == (booleanConstant true)) {
if (Direction == (booleanConstant false)) {
i2cSet 0 3 Speed
i2cSet 0 4 0
} else {
i2cSet 0 3 0
i2cSet 0 4 Speed
}
} else {
i2cSet 0 3 0
i2cSet 0 4 0
}
}
script 752 148 {
whenStarted
forever {
'Motor Driver A' false true 100
waitMillis 1000
'Motor Driver A' false false 50
waitMillis 1000
}
}
script 50 205 {
to 'Motor Driver B' {}
}
script 424 387 {
to 'Motor Driver A' {}
}
script 248 718 {
'Motor Driver B' true true 100
waitMillis 1000
'Motor Driver B' false false 100
waitMillis 1000
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

View File

@ -0,0 +1,11 @@
# Motor Driver Versions
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.
![](Images/1.png)
*Example*
Each of these two functions controls a different motor, allowing you to set the direction and speed for each motor.