diff --git a/Spark_Analog/Spark_Analog.ubl b/Spark_Analog/Spark_Analog.ubl new file mode 100644 index 0000000..0408ffb --- /dev/null +++ b/Spark_Analog/Spark_Analog.ubl @@ -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) +} + diff --git a/Spark_I2C/README.md b/Spark_I2C/README.md new file mode 100644 index 0000000..dfe587b --- /dev/null +++ b/Spark_I2C/README.md @@ -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 don’t 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 microcontroller’s pins (see your board’s 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!* + diff --git a/Spark_I2C/Spark_I2C.ubp b/Spark_I2C/Spark_I2C.ubp new file mode 100644 index 0000000..f8cc589 --- /dev/null +++ b/Spark_I2C/Spark_I2C.ubp @@ -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 +} + diff --git a/Spark_I2C/Spark_MotorDriver/Images/1.png b/Spark_I2C/Spark_MotorDriver/Images/1.png new file mode 100644 index 0000000..cd60aaa Binary files /dev/null and b/Spark_I2C/Spark_MotorDriver/Images/1.png differ diff --git a/Spark_I2C/Spark_MotorDriver/README.md b/Spark_I2C/Spark_MotorDriver/README.md index e69de29..b9c9133 100644 --- a/Spark_I2C/Spark_MotorDriver/README.md +++ b/Spark_I2C/Spark_MotorDriver/README.md @@ -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. \ No newline at end of file