summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratik-Nemane2025-05-05 16:38:31 +0530
committerGitHub2025-05-05 16:38:31 +0530
commitc3bae5bfb4bd1e5880adc2e0f92a2fe78192a30a (patch)
tree78570fcd86715842ba15659bf11ba8029c582d21
parent3e1f51a453ad06ef2cfa05db3c656290caf2580c (diff)
downloadFLOSS-Arduino-Book-c3bae5bfb4bd1e5880adc2e0f92a2fe78192a30a.tar.gz
FLOSS-Arduino-Book-c3bae5bfb4bd1e5880adc2e0f92a2fe78192a30a.tar.bz2
FLOSS-Arduino-Book-c3bae5bfb4bd1e5880adc2e0f92a2fe78192a30a.zip
Add files via upload
-rw-r--r--Jupyter-notebook/Physical computing with ESP32 and Micropython/Physical computing with ESP32 and Micropython.ipynb266
1 files changed, 202 insertions, 64 deletions
diff --git a/Jupyter-notebook/Physical computing with ESP32 and Micropython/Physical computing with ESP32 and Micropython.ipynb b/Jupyter-notebook/Physical computing with ESP32 and Micropython/Physical computing with ESP32 and Micropython.ipynb
index 2832f0f..efb4aaa 100644
--- a/Jupyter-notebook/Physical computing with ESP32 and Micropython/Physical computing with ESP32 and Micropython.ipynb
+++ b/Jupyter-notebook/Physical computing with ESP32 and Micropython/Physical computing with ESP32 and Micropython.ipynb
@@ -664,16 +664,7 @@
"source": [
"## Assignment\n",
"\n",
- "### Modify the given MicroPython code to turn on an LED connected to **pin 4**, keep it on for **3 seconds**, and then turn it off.\n",
- "\n",
- "### Requirements:\n",
- "- **LED**: \n",
- " - **LED** connected to **pin 4**.\n",
- "\n",
- "### Logic:\n",
- "1. Turn on the LED connected to **pin 4**.\n",
- "2. Keep the LED on for **3 seconds**.\n",
- "3. Turn off the LED after **3 seconds**."
+ "### Modify the given MicroPython code to turn on an LED connected to **pin 4**, keep it on for **3 seconds**, and then turn it off."
]
},
{
@@ -916,14 +907,8 @@
"## Assignment\n",
"\n",
"### Write a MicroPython program to detect a button press and display your name in the output window.\n",
- "\n",
- "### Requirements:\n",
- "\n",
- "- **Button**: \n",
- " - A button is connected to **pin 23**.\n",
- "\n",
- "### Logic:\n",
- "1. When the button is pressed, print your **Your name** in the output window."
+ "1. A button is connected to **pin 23**.\n",
+ "2. When the button is pressed, print your **Your name** in the output window."
]
},
{
@@ -1020,6 +1005,7 @@
"cell_type": "markdown",
"id": "6d978238-85ed-400d-af04-3b5645444696",
"metadata": {
+ "jp-MarkdownHeadingCollapsed": true,
"kernel": "SoS"
},
"source": [
@@ -1082,6 +1068,7 @@
"cell_type": "markdown",
"id": "276b7df7-fd86-41b6-9899-75b37621ed86",
"metadata": {
+ "jp-MarkdownHeadingCollapsed": true,
"kernel": "SoS"
},
"source": [
@@ -1145,18 +1132,9 @@
"\n",
"### Write a MicroPython program to turn on an LED when a button is pressed.\n",
"\n",
- "### Requirements:\n",
- "\n",
- "- **LED**: \n",
- " - **LED** connected to **pin 2**.\n",
- "\n",
- "- **Button**: \n",
- " - A button is connected to **pin 4**.\n",
- "\n",
- "### Logic:\n",
- "1. When the button connected to **pin 4** is pressed:\n",
- " - Turn on the **LED** connected to **pin 2**.\n",
- " - The LED should remain on for **2 seconds** before turning off.\n"
+ "1.When the button connected to pin 4 is pressed,\n",
+ "Turn on the LED connected to pin 2. \n",
+ "The LED should remain ON for 2 seconds before turning OFF."
]
},
{
@@ -1412,22 +1390,10 @@
"\n",
"### Write a MicroPython program to control three LEDs using a button press.\n",
"\n",
- "### Requirements:\n",
- "\n",
- "- **LEDs**: \n",
- " - **Red LED** connected to **pin 2**\n",
- " - **Green LED** connected to **pin 4**\n",
- " - **Blue LED** connected to **pin 5**\n",
- "\n",
- "- **Button**: \n",
- " - A button is connected to **pin 21**.\n",
- "\n",
- "### Logic:\n",
- "Each time the button is pressed:\n",
- "\n",
- "1. Light up one LED in sequence: **red → green → blue**.\n",
- "2. Only one LED should be on at a time.\n",
- "3. Each LED should stay on for **1 second**.\n"
+ "#### 1.Red LED connected to pin 2\n",
+ "#### 2.Green LED connected to pin 4\n",
+ "#### 3.Blue LED connected to pin 5\n",
+ "#### 4.Button is connected to pin 21.\n"
]
},
{
@@ -1855,6 +1821,19 @@
},
{
"cell_type": "markdown",
+ "id": "88b338aa-1af4-48c7-ad28-b5f9d91bdc03",
+ "metadata": {},
+ "source": [
+ "## Assighnment\n",
+ "### As an assignment:\n",
+ "\n",
+ "##### Connect a Buzzer instead of LED in the above circuit connection.\n",
+ "##### Upload the same program and check the output.\n",
+ "##### You would hear a noise with different frequencies."
+ ]
+ },
+ {
+ "cell_type": "markdown",
"id": "157e8926-2485-42fa-a354-e58044458275",
"metadata": {
"kernel": "SoS"
@@ -2099,6 +2078,28 @@
},
{
"cell_type": "markdown",
+ "id": "69fd7d6a-3279-44f6-a265-bc0411b74b46",
+ "metadata": {},
+ "source": [
+ "## Assignment\n",
+ "\n",
+ "### As an assignment:\n",
+ "##### Change the same program to display the digits in reverse order- 9,8,7,6,5,4,3,2,1,0.\n",
+ "##### Observe the digits displayed in the seven segment display.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "83998990-b11e-4050-b927-3fdf25144657",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# write your code here "
+ ]
+ },
+ {
+ "cell_type": "markdown",
"id": "42e67811-c206-4f09-806a-ce438375d9ed",
"metadata": {
"kernel": "SoS"
@@ -2331,6 +2332,22 @@
},
{
"cell_type": "markdown",
+ "id": "ec77bb5f-7456-4b3c-a47f-c8aa2d67b4a1",
+ "metadata": {},
+ "source": [
+ "## Assignment "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "f9a32120-1984-480d-a7b4-23a548119d9c",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
"id": "81e07556-ac4a-44d4-9ce7-f84dbb1a2302",
"metadata": {
"kernel": "SoS"
@@ -2491,8 +2508,6 @@
"\n",
"# Set up the LED pin as an output\n",
"led = Pin(LED_PIN, Pin.OUT)\n",
- "# Pin() is used to configure the GPIO pin\n",
- "# Pin.OUT sets the pin as an output\n",
"\n",
"# Set up the ADC on the light sensor pin\n",
"adc = ADC(Pin(LIGHT_SENSOR_PIN))\n",
@@ -2578,6 +2593,29 @@
},
{
"cell_type": "markdown",
+ "id": "c9db78df-8444-49ed-acb6-af90f40551aa",
+ "metadata": {},
+ "source": [
+ "## Assignment\n",
+ "#### Write a MicroPython program to monitor ambient light levels using an LDR connected to analog pin 14.\n",
+ "\n",
+ " 1. The program should turn ON an LED when the light intensity falls below a threshold value of 500.\n",
+ "\n",
+ " 2.The LED should be turned OFF when the light level rises above the threshold."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d049fe19-415f-482a-aeca-9b02b335e058",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# write you code here"
+ ]
+ },
+ {
+ "cell_type": "markdown",
"id": "41f1793e-13d0-49cb-8a9b-f0476072544f",
"metadata": {
"kernel": "SoS"
@@ -2814,6 +2852,36 @@
},
{
"cell_type": "markdown",
+ "id": "1b7b733e-6002-478a-bb89-302477c986dd",
+ "metadata": {},
+ "source": [
+ "## Assignment\n",
+ "\n",
+ "##### Write a MicroPython program to control a servo motor with a push button.\n",
+ "\n",
+ " On a single button press, the servo should perform the following actions:\n",
+ "\n",
+ " 1.Rotate to 90 degrees, wait 2 seconds\n",
+ "\n",
+ " 2.Rotate to 180 degrees, wait 2 seconds\n",
+ "\n",
+ " 3.Return to 0 degrees, wait 2 seconds\n",
+ "\n",
+ " Ensure the sequence runs only once per button press.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d9b6679b-38cf-4e13-a556-696da94c18c4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# write your code here"
+ ]
+ },
+ {
+ "cell_type": "markdown",
"id": "1f5237e1-12bd-495d-b285-1562e1176fca",
"metadata": {
"kernel": "SoS"
@@ -2837,6 +2905,7 @@
"cell_type": "markdown",
"id": "02963fb8-ad61-4f40-a1b8-3e1646e1ff72",
"metadata": {
+ "jp-MarkdownHeadingCollapsed": true,
"kernel": "SoS"
},
"source": [
@@ -3007,6 +3076,27 @@
},
{
"cell_type": "markdown",
+ "id": "a4c49ae2-a890-4550-9f77-8852481b109a",
+ "metadata": {},
+ "source": [
+ "## assignment \n",
+ "#### Write a MicroPython program that reads temperature using a thermistor\n",
+ "\n",
+ " If the temperature rises above a defined threshold, make the LED on pin 2 blink.\n",
+ "\n",
+ " If the temperature falls below the threshold, turn off the LED."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "88104b9d-1fc3-4c85-be88-c8073fb990a2",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
"id": "4bf63c64-4ab8-4895-8224-6dcf2db4d55f",
"metadata": {
"kernel": "SoS"
@@ -3170,6 +3260,31 @@
},
{
"cell_type": "markdown",
+ "id": "2a8d5f8c-8075-44e6-81e4-b2c0b294cfc7",
+ "metadata": {},
+ "source": [
+ "## Assignment\n",
+ "\n",
+ "#### Write a MicroPython program to read analog values from a potentiometer \n",
+ "connected to GPIO pin 23 on an ESP32 board.\n",
+ "\n",
+ " Configure the potentiometer pin as an ADC input.\n",
+ "\n",
+ " Continuously read and print the potentiometer value to the console.\n",
+ "\n",
+ " Implement a 2-second delay between readings to control the sampling rate.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "88bd95c8-29bd-42ef-bf45-5082757ae008",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
"id": "3b58d972-7a02-4814-b72a-a625aa59c43c",
"metadata": {
"kernel": "SoS"
@@ -3503,6 +3618,41 @@
},
{
"cell_type": "markdown",
+ "id": "ced77273-672e-461c-a90a-c0170dff73c0",
+ "metadata": {},
+ "source": [
+ "## Assighnment \n",
+ "#### Write a MicroPython program that performs the following tasks:\n",
+ "\n",
+ " Read the analog input from a potentiometer connected to GPIO pin 2.\n",
+ "\n",
+ " Use the potentiometer value to control the color of an RGB LED connected to GPIO pins 12 (Red), 13 (Green), and 14 (Blue).\n",
+ "\n",
+ " Map the potentiometer values in reverse order as follows:\n",
+ "\n",
+ " If the potentiometer value is less than or equal to 1500, turn the Green LED on and turn off the other LEDs.\n",
+ "\n",
+ " If the potentiometer value is between 1501 and 3000, turn the Blue LED on and turn off the other LEDs.\n",
+ "\n",
+ " If the potentiometer value is greater than 3000, turn the Red LED on and turn off the other LEDs.\n",
+ "\n",
+ " Use PWM to control the brightness of each LED based on the potentiometer value.\n",
+ "\n",
+ " Print the potentiometer value to the console continuously for monitoring."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "c710408a-7751-41b7-bc5e-721d7d7f3f01",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# write your code here "
+ ]
+ },
+ {
+ "cell_type": "markdown",
"id": "a1454e94-744c-4aea-b405-d3c7ecb63007",
"metadata": {
"kernel": "SoS"
@@ -4003,6 +4153,7 @@
"cell_type": "markdown",
"id": "8a74db1d-d1e1-4f94-b201-042bc13215c0",
"metadata": {
+ "jp-MarkdownHeadingCollapsed": true,
"kernel": "SoS"
},
"source": [
@@ -4280,6 +4431,9 @@
"\n",
"It provides APIs and tools for connecting devices, storing data in the cloud, and creating applications to interact with the data.\n",
"\n",
+ "## Configure Thingspeak \n",
+ "### To learn how configure on thingspeak, Visit spoken tutorial website :https://spoken-tutorial.org/watch/Arduino/Introduction+to+IoT/English/\n",
+ "\n",
"![Screenshot from 2024-03-21 15-04-12.png](attachment:98e7ea55-9351-4a30-87d7-63fc0be114e3.png)\n",
"\n",
"\n",
@@ -5124,22 +5278,6 @@
"#### Project Research Assistant, FOSSEE,IIT Bombay\n",
"\n"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "56f2cb73-4f19-4fba-924f-0d036d80c533",
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "b810a287-48d4-4383-8755-5bf887e85045",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {