summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratik-Nemane2025-06-16 12:27:11 +0530
committerGitHub2025-06-16 12:27:11 +0530
commit2ece9b0a6ea180624a9773784408d1e116a78d60 (patch)
tree76e7343de3cf357026e8fb34afd74bedf1a74a61
parentc3bae5bfb4bd1e5880adc2e0f92a2fe78192a30a (diff)
parent11f00c3c9e40bdcf4689e3c02e08c0a2de822efd (diff)
downloadFLOSS-Arduino-Book-master.tar.gz
FLOSS-Arduino-Book-master.tar.bz2
FLOSS-Arduino-Book-master.zip
Merge pull request #2 from Anushiya04/electroblocks-python-examplesHEADmaster
Add ElectroBlocks Python examples for Servo, RGB LED, and LED Blink
-rw-r--r--electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/LED_Blink-checkpoint.ipynb112
-rw-r--r--electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/RGB_LED-checkpoint.ipynb119
-rw-r--r--electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/Servo_Motor-checkpoint.ipynb106
-rw-r--r--electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/rgb-checkpoint.pngbin0 -> 119312 bytes
-rw-r--r--electroblocks_examples/electroblocks_examples/LED_Blink.ipynb112
-rw-r--r--electroblocks_examples/electroblocks_examples/RGB_LED.ipynb119
-rw-r--r--electroblocks_examples/electroblocks_examples/Servo_Motor.ipynb106
-rw-r--r--electroblocks_examples/electroblocks_examples/led.png.pngbin0 -> 91889 bytes
-rw-r--r--electroblocks_examples/electroblocks_examples/rgb.pngbin0 -> 119312 bytes
-rw-r--r--electroblocks_examples/electroblocks_examples/servo.pngbin0 -> 106168 bytes
10 files changed, 674 insertions, 0 deletions
diff --git a/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/LED_Blink-checkpoint.ipynb b/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/LED_Blink-checkpoint.ipynb
new file mode 100644
index 0000000..169da92
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/LED_Blink-checkpoint.ipynb
@@ -0,0 +1,112 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "76e999f4-b167-448e-b97c-cd00441adb7f",
+ "metadata": {},
+ "source": [
+ "# ElectroBlocks Demo 1: LED Blink using Arduino Uno\n",
+ "\n",
+ "## 🔍 Objective\n",
+ "### To blink the onboard LED on the Arduino Uno using ElectroBlocks in Python.\n",
+ "\n",
+ "## 📷 ElectroBlock Diagram\n",
+ "<img src=\"led.png.png\">\n",
+ "\n",
+ "## 🪛 Steps\n",
+ "### 1. Connect your Arduino Uno to the PC.\n",
+ "### 2. Upload the ElectroBlocks firmware using Arduino IDE.\n",
+ "### 3. Run the Python code below in this notebook.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "b269a315-9c92-433f-9584-bf04711657e4",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Collecting electroblocks==0.1.5\n",
+ " Downloading electroblocks-0.1.5-py3-none-any.whl.metadata (1.4 kB)\n",
+ "Requirement already satisfied: pyserial in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (from electroblocks==0.1.5) (3.5)\n",
+ "Downloading electroblocks-0.1.5-py3-none-any.whl (15 kB)\n",
+ "Installing collected packages: electroblocks\n",
+ " Attempting uninstall: electroblocks\n",
+ " Found existing installation: electroblocks 0.1.4\n",
+ " Uninstalling electroblocks-0.1.4:\n",
+ " Successfully uninstalled electroblocks-0.1.4\n",
+ "Successfully installed electroblocks-0.1.5\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install electroblocks==0.1.5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3bf7784c-0e3c-483a-9ea0-8d741e068695",
+ "metadata": {},
+ "source": [
+ "## Generated Python code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "64b67e81-d07a-4d26-b475-59c3e77cefac",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Import ElectroBlocks library\n",
+ "from electroblocks import ElectroBlocks\n",
+ "import time # imports the time library\n",
+ "\n",
+ "\n",
+ "# Initialise the program settings and configurations\n",
+ "eb = ElectroBlocks() # Create an instance of the ElectroBlocks class\n",
+ "\n",
+ "\n",
+ "\n",
+ "for i in range(1, 4):\n",
+ " eb.digital_write(13, 1) # Turns the led on\n",
+ " time.sleep(0.2); # Wait for the given/defined seconds.\n",
+ " eb.digital_write(13, 0) # Turns the led off\n",
+ " time.sleep(0.2); # Wait for the given/defined seconds."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "c0b90e66-c44f-4092-9ccd-bd6bb2aa4959",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.13.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/RGB_LED-checkpoint.ipynb b/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/RGB_LED-checkpoint.ipynb
new file mode 100644
index 0000000..d31fe61
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/RGB_LED-checkpoint.ipynb
@@ -0,0 +1,119 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "521c8062-37b9-4618-97ba-51c37e26be97",
+ "metadata": {},
+ "source": [
+ "# ElectroBlocks Demo 2: RGB LED Color Cycle using Arduino Uno\n",
+ "\n",
+ "## 🔍 Objective\n",
+ "### To cycle through red, green, and blue colors on an RGB LED using ElectroBlocks.\n",
+ "\n",
+ "## 📷 ElectroBlock Diagram\n",
+ "<img src=\"rgb.png\">\n",
+ "\n",
+ "## 🪛 Steps\n",
+ "### 1. Connect your Arduino Uno to the PC.\n",
+ "### 2. Upload the ElectroBlocks firmware using Arduino IDE.\n",
+ "### 3. Run the Python code below in this notebook."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "e88a79fd-b423-4834-904b-97b7b6aae881",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: electroblocks==0.1.5 in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (0.1.5)\n",
+ "Requirement already satisfied: pyserial in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (from electroblocks==0.1.5) (3.5)\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install electroblocks==0.1.5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "18bf100e-e48e-4d97-940b-976ada3685c8",
+ "metadata": {},
+ "source": [
+ "## Generated Python code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6c0ec0de-3a7a-44ae-a142-1b227fddea56",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Import ElectroBlocks library\n",
+ "from electroblocks import ElectroBlocks\n",
+ "\n",
+ "from dataclasses import dataclass\n",
+ "import time # imports the time library\n",
+ "\n",
+ "\n",
+ "@dataclass\n",
+ "class RGB:\n",
+ " red: float\n",
+ " green: float\n",
+ " blue: float\n",
+ "\n",
+ "\n",
+ "# Initialise the program settings and configurations\n",
+ "eb = ElectroBlocks() # Create an instance of the ElectroBlocks class\n",
+ "eb.config_rgb(11, 10, 9) # Configures the RGB LED pins\n",
+ "\n",
+ "\n",
+ "\n",
+ "for i in range(1, 4):\n",
+ " dev_color = RGB(255, 0, 0) # Create the RGB color object.\n",
+ " eb.set_rgb(dev_color.red, dev_color.green, dev_color.blue) # Set the RGB LED color on the Arduino.\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n",
+ " dev_color = RGB(0, 255, 0) # Create the RGB color object.\n",
+ " eb.set_rgb(dev_color.red, dev_color.green, dev_color.blue) # Set the RGB LED color on the Arduino.\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n",
+ " dev_color = RGB(0, 0, 255) # Create the RGB color object.\n",
+ " eb.set_rgb(dev_color.red, dev_color.green, dev_color.blue) # Set the RGB LED color on the Arduino.\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "3721ae90-e768-4113-b7c7-f9845db3198e",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.13.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/Servo_Motor-checkpoint.ipynb b/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/Servo_Motor-checkpoint.ipynb
new file mode 100644
index 0000000..21dead4
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/Servo_Motor-checkpoint.ipynb
@@ -0,0 +1,106 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "f166a431-70e0-45f2-bef5-f776af9388e4",
+ "metadata": {},
+ "source": [
+ "# ElectroBlocks Demo 3: Servo Motor Sweep\n",
+ "\n",
+ "## 🔍 Objective\n",
+ "### To sweep a servo motor from 0° to 180° and back using ElectroBlocks.\n",
+ "\n",
+ "## 📷 ElectroBlock Diagram\n",
+ "<img src=\"servo.png\">\n",
+ "\n",
+ "\n",
+ "## 🪛 Steps\n",
+ "### 1. Connect a servo motor to pin 5 of the Arduino Uno.\n",
+ "### 2. Power the servo externally or through Arduino 5V (if current is low).\n",
+ "### 3. Upload the ElectroBlocks firmware.\n",
+ "### 4. Run the following code."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "8d068e0d-2eea-47cc-aa97-0f09634314a5",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: electroblocks==0.1.5 in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (0.1.5)\n",
+ "Requirement already satisfied: pyserial in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (from electroblocks==0.1.5) (3.5)\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install electroblocks==0.1.5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0fa3a008-c4a2-4280-9104-b387a9ee59a4",
+ "metadata": {},
+ "source": [
+ "## Generated Python code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "0f2e6415-fc51-4aab-ae12-58767afb5044",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Import ElectroBlocks library\n",
+ "from electroblocks import ElectroBlocks\n",
+ "import time # imports the time library\n",
+ "\n",
+ "\n",
+ "# Initialise the program settings and configurations\n",
+ "eb = ElectroBlocks() # Create an instance of the ElectroBlocks class\n",
+ "eb.config_servo(5) # Configures the servo motor on pin 5\n",
+ "\n",
+ "\n",
+ "\n",
+ "while True:\n",
+ " eb.move_servo(5, 50) # Rotate servo position to 50 degrees\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n",
+ " eb.move_servo(5, 100) # Rotate servo position to 100 degrees\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "af5e2fee-353c-4930-85c0-4806801ceec8",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.13.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/rgb-checkpoint.png b/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/rgb-checkpoint.png
new file mode 100644
index 0000000..67dbb2c
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/.ipynb_checkpoints/rgb-checkpoint.png
Binary files differ
diff --git a/electroblocks_examples/electroblocks_examples/LED_Blink.ipynb b/electroblocks_examples/electroblocks_examples/LED_Blink.ipynb
new file mode 100644
index 0000000..169da92
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/LED_Blink.ipynb
@@ -0,0 +1,112 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "76e999f4-b167-448e-b97c-cd00441adb7f",
+ "metadata": {},
+ "source": [
+ "# ElectroBlocks Demo 1: LED Blink using Arduino Uno\n",
+ "\n",
+ "## 🔍 Objective\n",
+ "### To blink the onboard LED on the Arduino Uno using ElectroBlocks in Python.\n",
+ "\n",
+ "## 📷 ElectroBlock Diagram\n",
+ "<img src=\"led.png.png\">\n",
+ "\n",
+ "## 🪛 Steps\n",
+ "### 1. Connect your Arduino Uno to the PC.\n",
+ "### 2. Upload the ElectroBlocks firmware using Arduino IDE.\n",
+ "### 3. Run the Python code below in this notebook.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "b269a315-9c92-433f-9584-bf04711657e4",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Collecting electroblocks==0.1.5\n",
+ " Downloading electroblocks-0.1.5-py3-none-any.whl.metadata (1.4 kB)\n",
+ "Requirement already satisfied: pyserial in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (from electroblocks==0.1.5) (3.5)\n",
+ "Downloading electroblocks-0.1.5-py3-none-any.whl (15 kB)\n",
+ "Installing collected packages: electroblocks\n",
+ " Attempting uninstall: electroblocks\n",
+ " Found existing installation: electroblocks 0.1.4\n",
+ " Uninstalling electroblocks-0.1.4:\n",
+ " Successfully uninstalled electroblocks-0.1.4\n",
+ "Successfully installed electroblocks-0.1.5\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install electroblocks==0.1.5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3bf7784c-0e3c-483a-9ea0-8d741e068695",
+ "metadata": {},
+ "source": [
+ "## Generated Python code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "64b67e81-d07a-4d26-b475-59c3e77cefac",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Import ElectroBlocks library\n",
+ "from electroblocks import ElectroBlocks\n",
+ "import time # imports the time library\n",
+ "\n",
+ "\n",
+ "# Initialise the program settings and configurations\n",
+ "eb = ElectroBlocks() # Create an instance of the ElectroBlocks class\n",
+ "\n",
+ "\n",
+ "\n",
+ "for i in range(1, 4):\n",
+ " eb.digital_write(13, 1) # Turns the led on\n",
+ " time.sleep(0.2); # Wait for the given/defined seconds.\n",
+ " eb.digital_write(13, 0) # Turns the led off\n",
+ " time.sleep(0.2); # Wait for the given/defined seconds."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "c0b90e66-c44f-4092-9ccd-bd6bb2aa4959",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.13.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/electroblocks_examples/electroblocks_examples/RGB_LED.ipynb b/electroblocks_examples/electroblocks_examples/RGB_LED.ipynb
new file mode 100644
index 0000000..d31fe61
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/RGB_LED.ipynb
@@ -0,0 +1,119 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "521c8062-37b9-4618-97ba-51c37e26be97",
+ "metadata": {},
+ "source": [
+ "# ElectroBlocks Demo 2: RGB LED Color Cycle using Arduino Uno\n",
+ "\n",
+ "## 🔍 Objective\n",
+ "### To cycle through red, green, and blue colors on an RGB LED using ElectroBlocks.\n",
+ "\n",
+ "## 📷 ElectroBlock Diagram\n",
+ "<img src=\"rgb.png\">\n",
+ "\n",
+ "## 🪛 Steps\n",
+ "### 1. Connect your Arduino Uno to the PC.\n",
+ "### 2. Upload the ElectroBlocks firmware using Arduino IDE.\n",
+ "### 3. Run the Python code below in this notebook."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "e88a79fd-b423-4834-904b-97b7b6aae881",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: electroblocks==0.1.5 in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (0.1.5)\n",
+ "Requirement already satisfied: pyserial in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (from electroblocks==0.1.5) (3.5)\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install electroblocks==0.1.5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "18bf100e-e48e-4d97-940b-976ada3685c8",
+ "metadata": {},
+ "source": [
+ "## Generated Python code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6c0ec0de-3a7a-44ae-a142-1b227fddea56",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Import ElectroBlocks library\n",
+ "from electroblocks import ElectroBlocks\n",
+ "\n",
+ "from dataclasses import dataclass\n",
+ "import time # imports the time library\n",
+ "\n",
+ "\n",
+ "@dataclass\n",
+ "class RGB:\n",
+ " red: float\n",
+ " green: float\n",
+ " blue: float\n",
+ "\n",
+ "\n",
+ "# Initialise the program settings and configurations\n",
+ "eb = ElectroBlocks() # Create an instance of the ElectroBlocks class\n",
+ "eb.config_rgb(11, 10, 9) # Configures the RGB LED pins\n",
+ "\n",
+ "\n",
+ "\n",
+ "for i in range(1, 4):\n",
+ " dev_color = RGB(255, 0, 0) # Create the RGB color object.\n",
+ " eb.set_rgb(dev_color.red, dev_color.green, dev_color.blue) # Set the RGB LED color on the Arduino.\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n",
+ " dev_color = RGB(0, 255, 0) # Create the RGB color object.\n",
+ " eb.set_rgb(dev_color.red, dev_color.green, dev_color.blue) # Set the RGB LED color on the Arduino.\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n",
+ " dev_color = RGB(0, 0, 255) # Create the RGB color object.\n",
+ " eb.set_rgb(dev_color.red, dev_color.green, dev_color.blue) # Set the RGB LED color on the Arduino.\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "3721ae90-e768-4113-b7c7-f9845db3198e",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.13.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/electroblocks_examples/electroblocks_examples/Servo_Motor.ipynb b/electroblocks_examples/electroblocks_examples/Servo_Motor.ipynb
new file mode 100644
index 0000000..21dead4
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/Servo_Motor.ipynb
@@ -0,0 +1,106 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "f166a431-70e0-45f2-bef5-f776af9388e4",
+ "metadata": {},
+ "source": [
+ "# ElectroBlocks Demo 3: Servo Motor Sweep\n",
+ "\n",
+ "## 🔍 Objective\n",
+ "### To sweep a servo motor from 0° to 180° and back using ElectroBlocks.\n",
+ "\n",
+ "## 📷 ElectroBlock Diagram\n",
+ "<img src=\"servo.png\">\n",
+ "\n",
+ "\n",
+ "## 🪛 Steps\n",
+ "### 1. Connect a servo motor to pin 5 of the Arduino Uno.\n",
+ "### 2. Power the servo externally or through Arduino 5V (if current is low).\n",
+ "### 3. Upload the ElectroBlocks firmware.\n",
+ "### 4. Run the following code."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "8d068e0d-2eea-47cc-aa97-0f09634314a5",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: electroblocks==0.1.5 in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (0.1.5)\n",
+ "Requirement already satisfied: pyserial in c:\\users\\hai\\appdata\\local\\programs\\python\\python313\\lib\\site-packages (from electroblocks==0.1.5) (3.5)\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install electroblocks==0.1.5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0fa3a008-c4a2-4280-9104-b387a9ee59a4",
+ "metadata": {},
+ "source": [
+ "## Generated Python code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "0f2e6415-fc51-4aab-ae12-58767afb5044",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Import ElectroBlocks library\n",
+ "from electroblocks import ElectroBlocks\n",
+ "import time # imports the time library\n",
+ "\n",
+ "\n",
+ "# Initialise the program settings and configurations\n",
+ "eb = ElectroBlocks() # Create an instance of the ElectroBlocks class\n",
+ "eb.config_servo(5) # Configures the servo motor on pin 5\n",
+ "\n",
+ "\n",
+ "\n",
+ "while True:\n",
+ " eb.move_servo(5, 50) # Rotate servo position to 50 degrees\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n",
+ " eb.move_servo(5, 100) # Rotate servo position to 100 degrees\n",
+ " time.sleep(2) # Wait for the given/defined seconds.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "af5e2fee-353c-4930-85c0-4806801ceec8",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.13.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/electroblocks_examples/electroblocks_examples/led.png.png b/electroblocks_examples/electroblocks_examples/led.png.png
new file mode 100644
index 0000000..bd1378b
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/led.png.png
Binary files differ
diff --git a/electroblocks_examples/electroblocks_examples/rgb.png b/electroblocks_examples/electroblocks_examples/rgb.png
new file mode 100644
index 0000000..67dbb2c
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/rgb.png
Binary files differ
diff --git a/electroblocks_examples/electroblocks_examples/servo.png b/electroblocks_examples/electroblocks_examples/servo.png
new file mode 100644
index 0000000..46e871d
--- /dev/null
+++ b/electroblocks_examples/electroblocks_examples/servo.png
Binary files differ