This commit is contained in:
Fatima Idrees 2025-05-29 12:33:04 +03:00
commit 96d94c2c9e
4 changed files with 131 additions and 0 deletions

BIN
Images/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

69
README.md Normal file
View File

@ -0,0 +1,69 @@
# Button Library for MicroBlocks
Welcome to the **Button 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 a Button using simple blocks in MicroBlocks.
---
## Features
- **Easy drag-and-drop blocks** for controlling your Button
- **No coding required**
- **Turn on & off the Button**
- **Control the notes**
- **Beginner-friendly instructions**
---
## Getting Started
**What you need:**
- Spark microcontroller and connecting wires
- MicroBlocks IDE installed ([Download here](https://microblocks.fun/download/))
- A Button and basic connecting wires
---
## Installation
1. **Download the Button Library:**
Download the library file from [here](Spark_Digital.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 Button** to your microcontrollers pins (see your boards pinout for details).
2. **Open MicroBlocks IDE** and make sure your board is connected.
3. **Find the Button blocks** in the blocks menu.
4. **Drag the blocks** you want to use into your script area.
- For example:
- “Set Pin Value
- Turn Button On and Off
- Turn Inverted Button On and Off"
5. **Click the green flag** or “Run” to start controlling your Button!
---
## Example Project
![](Images/2.png)
After setting the pin value, there are two ways to use a Button:
1. You can simply turn it on or off.
2. You can adjust its notes.
---
*Have fun building with your Button!*

46
Spark_Digital.ubl Normal file
View File

@ -0,0 +1,46 @@
module Spark_Digital 'cat;Data'
author 'Fatima Idrees'
version 1 0
description ''
spec ' ' 'Buzzer' 'Buzzer Pin _ Tone _' 'num num' 5 1000
spec ' ' 'Buzzer2' 'Buzzer Pin _ State _' 'auto bool' 5 false
spec ' ' 'LED' 'LED Pin _ State _' 'num bool' 18 false
spec ' ' 'LED2 Pin' 'LED Pin _ Brightness _' 'num auto' 18 1000
spec 'r' 'Button Pin' 'Button Pin _' 'auto' 27
spec 'r' 'Inverted Button Pin' 'Inverted Button Pin _' 'auto' 27
to 'Button Pin' Input {
local 'Read1' (digitalReadOp Input 'up')
if (Read1 == (booleanConstant true)) {
return (not Read1)
} else {
return (booleanConstant true)
}
}
to Buzzer Pin Tone {
analogWriteOp Pin Tone
}
to Buzzer2 Pin State {
digitalWriteOp Pin State
}
to 'Inverted Button Pin' Input {
local 'Read2' (digitalReadOp Input 'up')
if (Read2 == (booleanConstant false)) {
return Read2
} else {
return (booleanConstant true)
}
}
to LED Pin State {
digitalWriteOp Pin State
}
to 'LED2 Pin' Pin Brightness {
analogWriteOp Pin Brightness
}

16
Versions/README.md Normal file
View File

@ -0,0 +1,16 @@
# Buzzer Library Development Steps
## Version 01
![](../Images/1.png)
It essentially turns the button on or off.
---
## Usage Example
![](../Images/2.png)
A way to test the function!