From 9a7b278272c2b942d6f4756cc7c83ef87f5cae6f Mon Sep 17 00:00:00 2001 From: Fatima Idrees Date: Tue, 3 Jun 2025 12:30:23 +0300 Subject: [PATCH] Uploading a new file --- Spark_Digital/Spark_Digital.ubl | 71 +++++++++++++++++++++++++++++++ Spark_Digital/Spark_LED/README.md | 22 ++++------ 2 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 Spark_Digital/Spark_Digital.ubl diff --git a/Spark_Digital/Spark_Digital.ubl b/Spark_Digital/Spark_Digital.ubl new file mode 100644 index 0000000..97fd012 --- /dev/null +++ b/Spark_Digital/Spark_Digital.ubl @@ -0,0 +1,71 @@ +module Spark_Digital 'cat;Data' +author 'Fab Lab BH' +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' 5 false + spec ' ' 'LED2 Pin' 'LED Pin _ Brightness _' 'num auto' 5 1000 + spec 'r' 'Button Pin' 'Button Pin _' 'auto' 27 + spec 'r' 'Inverted Button Pin' 'Inverted Button Pin _' 'auto' 1 + spec 'r' 'Photo Interrupter Pin' 'Photo Interrupter Pin _' 'num' 5 + spec 'r' 'Tilt Switch Pin' 'Tilt Switch Pin _' 'num' 5 + spec 'r' 'Touch Pin' 'Touch Pin _' 'num' 5 + spec ' ' 'Horn' 'Horn Pin _ State _' 'num bool' 5 true + spec ' ' 'Horn Pin' 'Horn Pin _ Tone _' 'num num' 5 1000 + +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 Horn Pin State { + digitalWriteOp Pin State +} + +to 'Horn Pin' Pin Tone { + analogWriteOp Pin Tone +} + +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 +} + +to 'Photo Interrupter Pin' Pin { + return (digitalReadOp Pin) +} + +to 'Tilt Switch Pin' Pin { + return (digitalReadOp Pin) +} + +to 'Touch Pin' Pin { + return (digitalReadOp Pin) +} + diff --git a/Spark_Digital/Spark_LED/README.md b/Spark_Digital/Spark_LED/README.md index 34a991b..6e02fea 100644 --- a/Spark_Digital/Spark_LED/README.md +++ b/Spark_Digital/Spark_LED/README.md @@ -7,27 +7,27 @@ This library makes it easy for anyone—even if you don’t know how to code or ## Features -- **Easy drag-and-drop blocks** for controlling your LED -- **No coding required** -- **Turn on & off the LED** -- **Control the brightness of the LED** -- **Beginner-friendly instructions** +- **Easy drag-and-drop blocks** for controlling your LED. +- **No coding required**. +- **Turn on & off the LED**. +- **Control the brightness of the LED**. +- **Beginner-friendly instructions**. --- ## Getting Started **What you need:** -- Spark microcontroller and connecting wires -- MicroBlocks IDE installed ([Download here](https://microblocks.fun/download/)) -- A LED and basic connecting wires +- Spark microcontroller and connecting wires. +- MicroBlocks IDE installed ([Download here](https://microblocks.fun/download/)). +- A LED and basic connecting wires. --- ## Installation 1. **Download the LED Library:** - Download the library file from [here](Spark_Digital.ubl). + Download the library file from [here](../Spark_Digital.ubl). 2. **Open MicroBlocks IDE** on your computer. @@ -46,10 +46,6 @@ This library makes it easy for anyone—even if you don’t know how to code or 3. **Find the LED blocks** in the blocks menu. 4. **Drag the blocks** you want to use into your script area. - - For example: - - “Set Pin Value - - Turn on the LED - - Control the Brightness" 5. **Click the green flag** or “Run” to start controlling your fan!