{"id":161,"date":"2026-02-26T00:08:09","date_gmt":"2026-02-26T00:08:09","guid":{"rendered":"https:\/\/learningfactorybox.com\/?page_id=161"},"modified":"2026-07-22T08:11:29","modified_gmt":"2026-07-22T08:11:29","slug":"teaching-material","status":"publish","type":"page","link":"https:\/\/learningfactorybox.com\/de\/teaching-material\/","title":{"rendered":"\ud83d\udce6 FactoryBox \u2013 Der Guide f\u00fcr Deine Lernerfahrung"},"content":{"rendered":"<h2 class=\"wp-block-post-title\">\ud83d\udce6 FactoryBox \u2013 A Teaching Guide<\/h2>\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Welcome! This guide helps you get started quickly with programming a<strong> FactoryBox<\/strong> using an<\/strong> <strong>ESP32 micro-controller<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2013 a beginner-friendly setup with LEDs, buttons, sensors, and displays connected to fixed GPIO pins.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2747\ufe0f Just focus on coding.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>If you&#8217;re completely new to ESP32, Arduino, and PlatformIO, we recommend reading through this guide first to get comfortable with the basics.<\/strong><br><br>But feel free to dive right in and experiment \u2013 if you ever get stuck, you can always come back here to find help.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-columns has-custom-uo-a-yellow-background-color has-background is-layout-flex wp-container-core-columns-is-layout-c6a03c77 wp-block-columns-is-layout-flex\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\">\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-center wp-block-paragraph\">Learn more about the concept behind the FactoryBox<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column has-medium-font-size is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-center has-small-font-size wp-block-paragraph\"><a href=\"https:\/\/learningfactorybox.com\/teaching-concept\/\" data-type=\"page\" data-id=\"727\">Concept behind LearningFactoryBox<\/a><\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns has-custom-uo-a-yellow-color has-custom-color-1-background-color has-text-color has-background has-link-color wp-elements-1 is-layout-flex wp-container-core-columns-is-layout-c6a03c77 wp-block-columns-is-layout-flex\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;padding-right:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)\">\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-center wp-block-paragraph\">Want to know what to program? What can the FactoryBox do?<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column has-medium-font-size is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-center has-small-font-size wp-block-paragraph\"><a href=\"https:\/\/learningfactorybox.com\/coding-challenges\/\" data-type=\"page\" data-id=\"227\">Look at these challenges<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-1&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h5 class=\"wp-block-accordion-heading has-custom-aalen-dark-pink-color has-text-color has-link-color wp-elements-2\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-1-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-1\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">Click here to open and <strong>read more<\/strong> about this guide.<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h5>\n\n\n\n<div aria-labelledby=\"accordion-item-1\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-1-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>You will learn how to:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Control LEDs and motors<\/li>\n\n\n\n<li>Read sensors<\/li>\n\n\n\n<li>Display information on screens<\/li>\n\n\n\n<li>Write your own creative programs to bring the box to life<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ll use the <strong>Arduino framework<\/strong> together with <strong>PlatformIO (PIO)<\/strong> \u2013 a powerful yet easy-to-use coding environment that&#8217;s especially popular among beginners and hobbyists.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The FactoryBox includes not only the ESP32 itself, but also an <strong>I2C GPIO expander (MCP23018)<\/strong> that gives you <strong>extra input\/output pins<\/strong> \u2013 perfect for adding more LEDs or buttons when the ESP32&#8217;s GPIOs run out.<\/p>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-3 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br>While this guide was created specifically for the <em>FactoryBox<\/em>, most of the examples and explanations apply just as well to any <strong>ESP32-based project<\/strong>.<br>If you&#8217;re using a different setup \u2013 or just learning how to program an ESP32 \u2013 you&#8217;ll still find this guide helpful.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide is a practical starting point designed for experimentation. As you grow more confident, explore links to advanced topics or search online to expand your ideas.<\/p>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-2&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h2 id=\"checklists\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-2-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-2\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\u2611\ufe0f Checklists for Quickstarters<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h2>\n\n\n\n<div aria-labelledby=\"accordion-item-2\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-2-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n<p class=\"has-custom-aalen-dark-pink-color has-text-color has-link-color wp-elements-4 wp-block-paragraph\"><em>These lists are <strong>clickable<\/strong> and will reset once you&#8217;ve reloaded the page.<\/em><\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<style>\n.checklist {\n  list-style: none;\n  padding: 0;\n  max-width: 500px;\n}\n\n.checklist li {\n  margin-bottom: 8px;\n}\n\n.checklist label {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  padding: 10px;\n  border: 2px solid #ccc;\n  border-radius: 6px;\n  cursor: pointer;\n  transition: background 0.3s, color 0.3s;\n}\n\n.checklist input[type=\"checkbox\"] {\n  display: none;\n}\n\n.checklist .box {\n  width: 18px;\n  height: 18px;\n  border: 2px solid #666;\n  border-radius: 3px;\n  position: relative;\n}\n\n\/* Checkmark *\/\n.checklist .box::after {\n  content: \"\u2714\";\n  position: absolute;\n  top: -2px;\n  left: 2px;\n  font-size: 14px;\n  color: #648A26;\n  opacity: 0;\n  transition: opacity 0.2s;\n}\n\n.checklist input[type=\"checkbox\"]:checked + label .box::after {\n  opacity: 1;\n}\n\n\/* Checked row *\/\n.checklist input[type=\"checkbox\"]:checked + label {\n  background-color: #648A26;\n  color: white;\n  border-color: #648A26;\n}\n\n.checklist input[type=\"checkbox\"]:checked + label .box {\n  border-color: white;\n}\n\n.checklist input[type=\"checkbox\"]:checked + label .box::after {\n  color: white;\n}\n\n\/* Progress *\/\n.progress-container {\n  max-width: 500px;\n  margin-bottom: 15px;\n}\n\n.progress-text {\n  margin-bottom: 5px;\n  font-weight: bold;\n}\n\n.progress-bg {\n  background: #eee;\n  border-radius: 10px;\n  overflow: hidden;\n}\n\n.progress-bar {\n  height: 20px;\n  width: 0%;\n  background-color: #648A26;\n  border-radius: 10px;\n  transition: width 0.3s;\n}\n\n.done-message {\n  display: none;\n  margin-top: 8px;\n  font-weight: bold;\n  color: #648A26;\n}\n<\/style>\n\n<h3>Setup Checklist<\/h3>\n\n<div class=\"progress-container\">\n  <div class=\"progress-text\" id=\"setupText\">0 \/ 6 completed<\/div>\n  <div class=\"progress-bg\">\n    <div class=\"progress-bar\" id=\"setupBar\"><\/div>\n  <\/div>\n  <div class=\"done-message\" id=\"setupDone\">\u2705 All done!<\/div>\n<\/div>\n\n<ul class=\"checklist\" id=\"setupList\">\n<li><input type=\"checkbox\" id=\"s0\"><label for=\"s0\"><span class=\"box\"><\/span>Open VSCode and load your project<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"s1\"><label for=\"s1\"><span class=\"box\"><\/span>Open box by opening the two halves to the side<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"s2\"><label for=\"s2\"><span class=\"box\"><\/span>Make sure power switch is turned off<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"s3\"><label for=\"s3\"><span class=\"box\"><\/span>Plug power cable in on back left side<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"s4\"><label for=\"s4\"><span class=\"box\"><\/span>Plug USB-C cable into backside of CNC housing<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"s5\"><label for=\"s5\"><span class=\"box\"><\/span>Check for blinking lights on ESP32<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"s6\"><label for=\"s6\"><span class=\"box\"><\/span>Turn on power switch<\/label><\/li>\n<\/ul>\n\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n  const list = document.getElementById(\"setupList\");\n  const checkboxes = list.querySelectorAll(\"input[type='checkbox']\");\n  const text = document.getElementById(\"setupText\");\n  const bar = document.getElementById(\"setupBar\");\n  const doneMsg = document.getElementById(\"setupDone\");\n\n  function update() {\n    const total = checkboxes.length;\n    const checked = list.querySelectorAll(\"input:checked\").length;\n    const percent = (checked \/ total) * 100;\n\n    text.textContent = checked + \" \/ \" + total + \" completed\";\n    bar.style.width = percent + \"%\";\n    doneMsg.style.display = (checked === total) ? \"block\" : \"none\";\n  }\n\n  checkboxes.forEach(cb => cb.addEventListener(\"change\", update));\n  update();\n});\n<\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<style>\n\/* Same styles reused *\/\n.checklist {\n  list-style: none;\n  padding: 0;\n  max-width: 500px;\n}\n\n.checklist li {\n  margin-bottom: 8px;\n}\n\n.checklist label {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  padding: 10px;\n  border: 2px solid #ccc;\n  border-radius: 6px;\n  cursor: pointer;\n}\n\n.checklist input[type=\"checkbox\"] {\n  display: none;\n}\n\n.checklist .box {\n  width: 18px;\n  height: 18px;\n  border: 2px solid #666;\n  border-radius: 3px;\n  position: relative;\n}\n\n.checklist .box::after {\n  content: \"\u2714\";\n  position: absolute;\n  top: -2px;\n  left: 2px;\n  font-size: 14px;\n  color: #648A26;\n  opacity: 0;\n}\n\n.checklist input[type=\"checkbox\"]:checked + label {\n  background-color: #648A26;\n  color: white;\n  border-color: #648A26;\n}\n\n.checklist input[type=\"checkbox\"]:checked + label .box::after {\n  opacity: 1;\n  color: white;\n}\n\n.checklist input[type=\"checkbox\"]:checked + label .box {\n  border-color: white;\n}\n\n\/* Progress *\/\n.progress-container {\n  max-width: 500px;\n  margin-bottom: 15px;\n}\n\n.progress-text {\n  margin-bottom: 5px;\n  font-weight: bold;\n}\n\n.progress-bg {\n  background: #eee;\n  border-radius: 10px;\n  overflow: hidden;\n}\n\n.progress-bar {\n  height: 20px;\n  width: 0%;\n  background-color: #648A26;\n  border-radius: 10px;\n}\n\n.done-message {\n  display: none;\n  margin-top: 8px;\n  font-weight: bold;\n  color: #648A26;\n}\n<\/style>\n\n<h3>Close-up Checklist<\/h3>\n\n<div class=\"progress-container\">\n  <div class=\"progress-text\" id=\"closingText\">0 \/ 4 completed<\/div>\n  <div class=\"progress-bg\">\n    <div class=\"progress-bar\" id=\"closingBar\"><\/div>\n  <\/div>\n  <div class=\"done-message\" id=\"closingDone\">\u2705 All done!<\/div>\n<\/div>\n\n<ul class=\"checklist\" id=\"closingList\">\n<li><input type=\"checkbox\" id=\"c0\"><label for=\"c0\"><span class=\"box\"><\/span>Save your code and close VSCode<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"c1\"><label for=\"c1\"><span class=\"box\"><\/span>Turn off power switch<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"c2\"><label for=\"c2\"><span class=\"box\"><\/span>Make sure all cables are disconnected!!<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"c3\"><label for=\"c3\"><span class=\"box\"><\/span>Make sure the CNC lid is fully seated<\/label><\/li>\n  <li><input type=\"checkbox\" id=\"c4\"><label for=\"c4\"><span class=\"box\"><\/span>Close box and store it safely<\/label><\/li>\n<\/ul>\n\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n  const list = document.getElementById(\"closingList\");\n  const checkboxes = list.querySelectorAll(\"input[type='checkbox']\");\n  const text = document.getElementById(\"closingText\");\n  const bar = document.getElementById(\"closingBar\");\n  const doneMsg = document.getElementById(\"closingDone\");\n\n  function update() {\n    const total = checkboxes.length;\n    const checked = list.querySelectorAll(\"input:checked\").length;\n    const percent = (checked \/ total) * 100;\n\n    text.textContent = checked + \" \/ \" + total + \" completed\";\n    bar.style.width = percent + \"%\";\n    doneMsg.style.display = (checked === total) ? \"block\" : \"none\";\n  }\n\n  checkboxes.forEach(cb => cb.addEventListener(\"change\", update));\n  update();\n});\n<\/script>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: true, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-3&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h2 id=\"toc\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-3-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-3\" type=\"button\" class=\"wp-block-accordion-heading__toggle\" style=\"padding-top:0;padding-bottom:0\"><span class=\"wp-block-accordion-heading__toggle-title\">\ud83d\udcd6 Table of Contents<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h2>\n\n\n\n<div aria-labelledby=\"accordion-item-3\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-3-panel\" role=\"region\" class=\"wp-block-accordion-panel has-custom-aalen-purple-color has-text-color has-link-color wp-elements-5 is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n<nav aria-label=\"Inhaltsverzeichnis\" class=\"wp-block-table-of-contents\"><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#hardware-information\">Hardware Information<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#esp32---microcontroller\">\ud83e\udde0 ESP32 &#8211; Microcontroller<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#hardware-overview\">Hardware Overview<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#general-pin-layout\">General Pin Layout<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#pins-safe-to-use\">Pins safe to use<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#mcp23018-gpio-expander\">\ud83d\udd0c MCP23018 &#8211; GPIO Expander<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#key-features\">Key Features:<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#gpio-structure-and-configuration\">GPIO Structure and Configuration<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#factorybox\">\ud83e\uddf0 FactoryBox<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#sensor-layout\">Sensor Layout<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#gpio-pinout\">GPIO Pinout<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#esp32-gpio-pinout\">ESP32 GPIO Pinout<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#mcp23018-gpio-pinout\">MCP23018 GPIO Pinout<\/a><\/li><\/ol><\/li><\/ol><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#coding-information\">Coding Information<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#platformio-ide\">\ud83e\uddd1\u200d\ud83d\udcbb PlatformIO IDE<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#overview\">Overview<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#installing-platformio-in-vscode\">Installing PlatformIO in VSCode<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#create-a-new-project\">Create a New Project<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#open-an-existing-platformio-project\">Open an Existing PlatformIO Project<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#project-folder-structure\">Project Folder Structure<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#libraries\">Libraries<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#install-a-library\">Install a Library:<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#uninstall-a-library\">Uninstall a Library:<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#manually-install-a-library-from-github\">Manually Install a Library from GitHub:<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#run-your-code\">Run Your Code<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#arduino-ide\">\u2733\ufe0fArduino IDE<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#important\">\u2757IMPORTANT<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#installing-esp32-dependencies-from-boardmanager\">Installing ESP32 Dependencies from Boardmanager<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#create-a-new-project-1\">Create a new Project<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#open-existing-project\">Open existing Project<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#folder-structure-or-lack-thereof\">Folder structure (or lack thereof)<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#libraries-1\">Libraries<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#run-your-code-1\">Run your code<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#arduino-code-structure\">\ud83e\udde9 Arduino Code Structure<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#what-is-arduino\">What is Arduino?<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#libraries-and-definitions\">Libraries and Definitions<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#the-setup-code\">The Setup Code<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#the-loop-code\">The Loop Code<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#common-functions-you-ll-use\">\ud83d\udca1 Common Functions You&#8217;ll Use<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#pin-configuration\">Pin Configuration<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#serial-communication\">Serial Communication<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#read-write-data\">Read\/Write Data<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#timing-and-logic\">Timing and Logic<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#utility-functions\">Utility Functions<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#examples-your-starting-point\">\ud83d\ude80 Examples \u2013 Your Starting Point<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#blink-an-led-your-first-example\">Blink an LED \u2013 Your First Example<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#debugging\">\u2620\ufe0f Debugging<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/learningfactorybox.com\/teaching-material\/#further-learning\">\ud83d\udcd6 Further Learning<\/a><\/li><\/ol><\/li><\/ol><\/nav>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 id=\"hardware-information\" class=\"wp-block-heading\"><strong>Hardware Information<\/strong><\/h2>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-4&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 id=\"esp32---microcontroller\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-4-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-4\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\ud83e\udde0 ESP32 &#8211; Microcontroller<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-4\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-4-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">This chapter introduces the ESP32 microcontroller, highlights its key features, and gives an overview of its GPIO pins and the functions they can perform.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#hardware-overview\">Hardware Overview<\/a><\/li>\n\n\n\n<li><a href=\"#general-pin-layout\">Genreal Pin-Layout<\/a><\/li>\n\n\n\n<li><a href=\"#pins-safe-to-use\">Pins safe to use<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Meet the brain of your FactoryBox:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"300\" height=\"151\" data-attachment-id=\"1171\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/esp32-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/esp32-edited-1.png?fit=300%2C151&amp;ssl=1\" data-orig-size=\"300,151\" data-comments-opened=\"1\" data-image-title=\"esp32\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/esp32-edited-1.png?fit=300%2C151&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/esp32-edited-1.png?resize=300%2C151&#038;ssl=1\" alt=\"\" class=\"wp-image-1171\" title=\"ESP32 Dev Board\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"hardware-overview\" class=\"wp-block-heading\"><strong>Hardware Overview<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The ESP32 is a low-cost, ultra-low power microcontroller with integrated Wi-Fi and dual-mode Bluetooth. It is suitable for a wide variety of applications\u2013from low-power sensor networks to voice encoding, music streaming, and MP3 decoding. The ESP32 is a successor to the ESP8266 and is produced by Espressif Systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key Features:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dual-core 32-bit processor (up to 240 MHz)<\/li>\n\n\n\n<li>520 KB SRAM (Static RAM, for variables and data)<\/li>\n\n\n\n<li>Built-in Wi-Fi and Bluetooth (Classic + BLE)<\/li>\n\n\n\n<li>Many GPIOs with support for PWM, ADC, DAC, SPI, I2C, UART, and more<\/li>\n\n\n\n<li>Deep sleep mode for energy saving<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Generally, you will use a development board with an ESP32 chip that includes a USB-to-serial converter, a voltage regulator, and pin headers. The development board for this project is equipped with the ESP-WROOM-32 module.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To expand the number of available GPIOs, the FactoryBox also includes an <a href=\"#mcp23018-gpio-expander\" data-type=\"internal\" data-id=\"#mcp23018-gpio-expander\"><strong>MCP23018 I2C GPIO expander<\/strong><\/a>. This chip connects to the ESP32 over the I2C bus and adds 16 additional digital input\/output pins. It&#8217;s ideal for components that <strong>don&#8217;t need to be connected directly to the ESP32<\/strong>, helping you <strong>save valuable GPIO pins<\/strong> for more critical or timing-sensitive tasks.<\/p>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-6 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udca1 <strong>Tip:<\/strong><br>Last Minute Engineers&#8217; <a href=\"https:\/\/lastminuteengineers.com\/getting-started-with-esp32\/\">Getting Started with ESP32<\/a> guide provides a well-structured and detailed introduction to the ESP32, complete with practical examples and various use cases that will appeal to both beginners and experienced users.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#esp32---microcontroller\">\ud83e\udde0 ESP32<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"general-pin-layout\" class=\"wp-block-heading\"><strong>General Pin Layout<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The ESP32 features a versatile set of GPIO pins, each with specific functions and limitations.<br><br>You can configure these pins as inputs or outputs using the <code>pinMode()<\/code> function. Once configured, you can read their state with <code>digitalRead()<\/code> or set their state with <code>digitalWrite()<\/code>.<br><br>For more details on these functions, please see the dedicated section: <a href=\"#-common-functions-youll-use\">\ud83d\udca1 Common Functions You&#8217;ll Use<\/a>.<br><br>The internal registers also allow you to enable built-in pull-up or pull-down resistors, offering a flexible platform for interfacing with various sensors and actuators.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The diagrams and tables below help you identify which pins are available for your projects:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-css wp-custom-css-6ce7fd13\"><img data-recalc-dims=\"1\" decoding=\"async\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/mischianti.org\/wp-content\/uploads\/2021\/07\/ESP32-DEV-KIT-DevKitC-v4-pinout-mischianti.png?ssl=1\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Pinout Diagram ESP32, 38 pins <a href=\"https:\/\/mischianti.org\/wp-content\/uploads\/2021\/07\/ESP32-DEV-KIT-DevKitC-v4-pinout-mischianti.png\">(Source)<\/a><\/figcaption><\/figure>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-7 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br>While the internal GPIO numbers (like GPIO23) are consistent across all ESP32 development boards, the physical layout (pin position and labeling) may vary depending on your specific board. The pinout images below show a common layout, but they may not be a 1:1 match with your board&#8217;s exact design.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#esp32---microcontroller\">\ud83e\udde0 ESP32<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"pins-safe-to-use\" class=\"wp-block-heading\"><strong>Pins safe to use<\/strong><\/h4>\n\n\n\n<p class=\"has-base-color has-custom-aalen-dark-pink-background-color has-text-color has-background has-link-color wp-elements-8 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\u26a0\ufe0f <strong>Warning:<\/strong><br>Some ESP32 pins are reserved for specific purposes (e.g., internal flash memory, boot mode selection, input-only) and should not be used for general-purpose I\/O. Check the pin reference carefully before using a pin in your project.<\/p>\n\n\n\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"680\" height=\"1532\" data-attachment-id=\"396\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/esp32_table_safe_pins\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/esp32_table_safe_pins.png?fit=680%2C1532&amp;ssl=1\" data-orig-size=\"680,1532\" data-comments-opened=\"1\" data-image-title=\"esp32_table_safe_pins\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/esp32_table_safe_pins.png?fit=455%2C1024&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/esp32_table_safe_pins.png?resize=680%2C1532&#038;ssl=1\" alt=\"\" class=\"wp-image-396\" title=\"Table of ESP32 Safe Pins (by Last Minute Engineers)\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/esp32_table_safe_pins.png?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/esp32_table_safe_pins.png?resize=133%2C300&amp;ssl=1 133w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/esp32_table_safe_pins.png?resize=455%2C1024&amp;ssl=1 455w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure>\n<\/div>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-9 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udca1 <strong>Tip:<\/strong><br>For detailed information about the pins, please refer to the <a href=\"https:\/\/lastminuteengineers.com\/esp32-pinout-reference\/\"><strong>ESP32 Pinout Reference<\/strong><\/a> by Last Minute Engineers, which gives a great overview of the ESP32 pin layout and the different functions of the pins. You can also consult the datasheet of the ESP32 Dev Board you are using.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#esp32---microcontroller\" data-type=\"internal\" data-id=\"#esp32---microcontroller\">\ud83e\udde0 ESP32<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-5&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 id=\"mcp23018-gpio-expander\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-5-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-5\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\ud83d\udd0c MCP23018 &#8211; GPIO Expander<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-5\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-5-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">The <strong>MCP23018<\/strong> is an <strong>I2C-based GPIO expander<\/strong> used in the FactoryBox to provide <strong>16 additional digital input\/output pins<\/strong> \u2013 ideal for connecting more <strong>buttons, LEDs, and basic output components<\/strong> when your ESP32 runs out of GPIOs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"300\" height=\"168\" data-attachment-id=\"397\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/mcp23018\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/mcp23018.png?fit=300%2C168&amp;ssl=1\" data-orig-size=\"300,168\" data-comments-opened=\"1\" data-image-title=\"mcp23018\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/mcp23018.png?fit=300%2C168&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/mcp23018.png?resize=300%2C168&#038;ssl=1\" alt=\"\" class=\"wp-image-397\" title=\"MCP23018 GPIO Expander\"\/><\/figure>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"key-features\" class=\"wp-block-heading\"><strong>Key Features:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Wide Voltage Compatibility:<\/strong> Operates over a broad range (typically 2.5V to 5.5V), ensuring seamless integration with both 3.3V and 5V systems.<\/li>\n\n\n\n<li><strong>Built-In Pull-Up Resistors:<\/strong> Helps stabilize input signals without requiring extra external components.<\/li>\n\n\n\n<li><strong>Open-Drain Outputs:<\/strong> Designed to pull lines low, perfect for many basic applications but requiring external circuitry if a push-pull high is needed.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The chip communicates with the ESP32 over the I2C bus using only two dedicated pins (SDA and SCL), helping conserve precious microcontroller resources.<\/p>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-10 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udca1 <strong>Tip:<\/strong><br><strong>New to I2C?<\/strong> Check out the official <a href=\"https:\/\/docs.arduino.cc\/learn\/communication\/wire\/\"><strong>Arduino I2C (Wire) Documentation<\/strong><\/a> to understand how I2C communication works and how to use it in your own projects.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By integrating the MCP23018, you can significantly expand your system&#8217;s I\/O capabilities without using up additional ESP32 pins \u2013 leaving more room for time-sensitive tasks or other peripherals.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Datasheet:<\/strong><a href=\"https:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/22103a.pdf\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">MCP23018 \u2013 I2C GPIO Expander (Microchip)<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"gpio-structure-and-configuration\" class=\"wp-block-heading\">GPIO Structure and Configuration<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The 16 GPIOs are split into two 8-bit ports (see image above):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Port A<\/strong>: GPA0 to GPA7<\/li>\n\n\n\n<li><strong>Port B<\/strong>: GPB0 to GPB7<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Each pin can be <strong>individually configured<\/strong> as an <strong>input or output<\/strong>, and the expander&#8217;s registers allow you to set the direction, enable built-in pull-ups, and read or write the pin states.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Although you can manipulate these registers directly, it&#8217;s common to use a <strong>library<\/strong> (e.g. <a href=\"https:\/\/github.com\/wollewald\/MCP23017_WE\"><strong>MCP23017_WE<\/strong> by Wolfgang Ewald<\/a>) which abstracts away the low-level details. This way, after setup you can control the pins just like you would the ESP32&#8217;s native GPIOs.<\/p>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-11 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br><strong>I2C Address:<\/strong> <code>0x20<\/code><br>The MCP23018 features a <strong>multi-bit analog address decoder<\/strong>, allowing up to <strong>eight unique I2C addresses<\/strong> using just a <strong>single address pin (ADDR)<\/strong>.<br>It selects the address based on the voltage level present on ADDR, using an internal voltage comparator.<br>In the <strong>FactoryBox<\/strong>, this pin is <strong>connected to GND<\/strong>, so the MCP23018 uses the <strong>address <code>0x20<\/code><\/strong>.<\/p>\n\n\n\n<p class=\"has-base-color has-custom-aalen-dark-pink-background-color has-text-color has-background has-link-color wp-elements-12 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\u26a0\ufe0f <strong>Caution:<\/strong><br>Not all components are suitable for the MCP23018!<br>Its <strong>outputs are open-drain<\/strong>, which means it can pull a line low but not drive it high.<br>This is fine for <strong>LEDs, buttons and buzzers (or similar)<\/strong>, but <strong>won&#8217;t work<\/strong> with components like <strong>servos, NeoPixels<\/strong>, or other devices that require push-pull or precisely timed signals.<\/p>\n\n\n\n<p class=\"has-custom-color-4-color has-custom-orange-background-color has-text-color has-background has-link-color wp-elements-13 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udca1 <strong>Tip:<\/strong><br>For more flexible output capabilities, consider using the <strong>MCP23017<\/strong> instead.<br>It features <strong>push-pull outputs<\/strong> (making it suitable for a wider range of components) and is even <strong>more popular<\/strong> in the maker community.<br>It also supports up to eight devices on the I2C bus using <strong>simple address pins<\/strong> (A0\u2013A2), making configuration easier than with the MCP23018.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#mcp23018---gpio-expander\" data-type=\"internal\" data-id=\"#mcp23018---gpio-expander\">\ud83d\udd0c MCP23018 &#8211; GPIO Expander<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-10&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 id=\"factorybox\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-10-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-10\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\ud83e\uddf0 FactoryBox<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-10\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-10-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">The FactoryBox is a pre-wired learning environment built around the ESP32.<br><br>It includes LEDs, buttons, sensors, displays, and other components connected to specific GPIO pins.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide uses those predefined pin numbers in all <code>examples<\/code>.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<h4 id=\"sensor-layout\" class=\"wp-block-heading\"><strong>Sensor Layout<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-gallery alignfull has-nested-images columns-default is-cropped wp-block-gallery-6 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\" style=\"margin-top:var(--wp--preset--spacing--40);margin-right:var(--wp--preset--spacing--60);margin-bottom:var(--wp--preset--spacing--40);margin-left:var(--wp--preset--spacing--60)\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"3004\" height=\"1519\" data-attachment-id=\"234\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/?attachment_id=234\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/factorybox-diagram-1.png?fit=3004%2C1519&amp;ssl=1\" data-orig-size=\"3004,1519\" data-comments-opened=\"1\" data-image-title=\"FactoryBox Diagram\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;FactoryBox Sensor Layout&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/factorybox-diagram-1.png?fit=1024%2C518&amp;ssl=1\" fetchpriority=\"low\" data-id=\"234\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/factorybox-diagram-1.png?resize=3004%2C1519&#038;ssl=1\" alt=\"\" class=\"wp-image-234\"\/><\/figure>\n<\/figure>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<h4 id=\"gpio-pinout\" class=\"wp-block-heading\"><strong>GPIO Pinout<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Each component in the FactoryBox is wired to a specific GPIO pin on the ESP32 and MCP23018.<br><br>The table below shows which pin is used for what \u2013 so you don&#8217;t need to guess or trace any wiring.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#esp32-gpio-pinout\">ESP32 GPIO Pinout<\/a><\/li>\n\n\n\n<li><a href=\"#mcp23018-gpio-pinout\">MCP23018 GPIO Pinout<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll use these GPIO numbers directly in your code when controlling LEDs, reading sensors, or displaying data.<\/p>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-14 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br>The <strong>Part-ID<\/strong> refers to the table <a href=\"#\"><code>electronic_parts_list.xlsx<\/code><\/a> in the <a href=\"https:\/\/learningfactorybox.com\/building-files\/\"><strong>Building Files<\/strong><\/a>.<br>It identifies the exact components used in this FactoryBox \u2013 useful if you want to look up more information about a part online, or if you&#8217;re trying to source the correct parts to rebuild the system exactly.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h5 id=\"esp32-gpio-pinout\" class=\"wp-block-heading\"><strong>ESP32 GPIO Pinout<\/strong><\/h5>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>GPIO<\/th><th>Part<\/th><th>Part-ID<\/th><th>Area<\/th><th>Input\/Output<\/th><\/tr><\/thead><tbody><tr><td>36<\/td><td>LDR<\/td><td>32<\/td><td>2<\/td><td>Input, Analog<\/td><\/tr><tr><td>39<\/td><td>Photoelectric Counter<\/td><td>48<\/td><td>1<\/td><td>Input, Digital<\/td><\/tr><tr><td>34<\/td><td>Grove Air Quality Sensor<\/td><td>58<\/td><td>3<\/td><td>Input, Analog<\/td><\/tr><tr><td>35<\/td><td>Push Button #4 (Reset)<\/td><td>44<\/td><td>3<\/td><td>Input, Digital<\/td><\/tr><tr><td>32<\/td><td>Stepper Motor with Driver &#8211; IN4<\/td><td>51<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>33<\/td><td>Stepper Motor with Driver &#8211; IN3<\/td><td>51<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>25<\/td><td>Stepper Motor with Driver &#8211; IN2<\/td><td>51<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>26<\/td><td>Stepper Motor with Driver &#8211; IN1<\/td><td>51<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>27<\/td><td>Solenoid<\/td><td>46<\/td><td>1<\/td><td>Output, Digital<\/td><\/tr><tr><td>14<\/td><td>Fan<\/td><td>47<\/td><td>1<\/td><td>Output, analog (PWM)<\/td><\/tr><tr><td>12<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>13<\/td><td>RGBW LED Strip (SK6812)<\/td><td>40<\/td><td>1<\/td><td>Output, Digital<\/td><\/tr><tr><td>15<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>2<\/td><td>Servo #1<\/td><td>49<\/td><td>1<\/td><td>Output, analog (PWM)<\/td><\/tr><tr><td>0<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>4<\/td><td>Servo #2<\/td><td>50<\/td><td>3<\/td><td>Output, analog (PWM)<\/td><\/tr><tr><td>16<\/td><td>Grove 4-Digit Display &#8211; DCLK<\/td><td>56<\/td><td>1<\/td><td>Output, Digital<\/td><\/tr><tr><td>17<\/td><td>DHT11<\/td><td>55<\/td><td>3<\/td><td>Bidirectional, Digital<\/td><\/tr><tr><td>5<\/td><td>Grove 4-Digit Display &#8211; DIO<\/td><td>56<\/td><td>1<\/td><td>Output, Digital<\/td><\/tr><tr><td>18<\/td><td>Grove LED-Bar &#8211; DI<\/td><td>57<\/td><td>3<\/td><td>Output, Digital<\/td><\/tr><tr><td>19<\/td><td>Grove LED-Bar &#8211; DCKI<\/td><td>57<\/td><td>3<\/td><td>Output, Digital<\/td><\/tr><tr><td>21<\/td><td>MCP23018 (I2C GPIO Expander) &#8211; SDA<\/td><td>52<\/td><td>2<\/td><td>I2C (Digital)<\/td><\/tr><tr><td>21<\/td><td>I2C LCD Display &#8211; SDA<\/td><td>53<\/td><td>2<\/td><td>I2C (Digital)<\/td><\/tr><tr><td>21<\/td><td>I2C TOF Sensor &#8211; SDA<\/td><td>54<\/td><td>2<\/td><td>I2C (Digital)<\/td><\/tr><tr><td>3<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>1<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>22<\/td><td>MCP23018 (I2C GPIO Expander) &#8211; SCL<\/td><td>52<\/td><td>2<\/td><td>I2C (Digital)<\/td><\/tr><tr><td>22<\/td><td>I2C LCD Display &#8211; SCL<\/td><td>53<\/td><td>2<\/td><td>I2C (Digital)<\/td><\/tr><tr><td>22<\/td><td>I2C TOF Sensor &#8211; SCL<\/td><td>54<\/td><td>2<\/td><td>I2C (Digital)<\/td><\/tr><tr><td>23<\/td><td>LED White #3 (Lighting)<\/td><td>36<\/td><td>3<\/td><td>Output, Digital<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>NC = Not Connected<br><br>Area:<\/strong> 1 = Incoming Goods, 2 = Manufacturing, 3 = Outgoing Goods<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#factorybox\">\ud83e\uddf0 FactoryBox<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h5 id=\"mcp23018-gpio-pinout\" class=\"wp-block-heading\"><strong>MCP23018 GPIO Pinout<\/strong><\/h5>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>GPIO<\/th><th>Part<\/th><th>Part-ID<\/th><th>Area<\/th><th>Notes<\/th><\/tr><\/thead><tbody><tr><td>B0<\/td><td>Push Button #1 (Start\/Stop)<\/td><td>41<\/td><td>2<\/td><td>Input, Digital<\/td><\/tr><tr><td>B1<\/td><td>LED Blue (Start\/Stop)<\/td><td>39<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>B2<\/td><td>Push Button #2 (Light Switch)<\/td><td>42<\/td><td>2<\/td><td>Input, Digital<\/td><\/tr><tr><td>B3<\/td><td>LED White #4 (Light Switch)<\/td><td>34<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>B4<\/td><td>Push Button #3 (Emergency Stop)<\/td><td>43<\/td><td>2<\/td><td>Input, Digital<\/td><\/tr><tr><td>B5<\/td><td>LED Red #2 (Emergency Stop)<\/td><td>38<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>B6<\/td><td>LED White #1 (Lighting)<\/td><td>33<\/td><td>1<\/td><td>Output, Digital<\/td><\/tr><tr><td>B7<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>A0<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>A1<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>A2<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>A3<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>A4<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><td>NC<\/td><\/tr><tr><td>A5<\/td><td>LED Red #1 (Alert TOF Sensor)<\/td><td>37<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>A6<\/td><td>Buzzer (Alert TOF Sensor)<\/td><td>45<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><tr><td>A7<\/td><td>LED White #2 (Lighting)<\/td><td>35<\/td><td>2<\/td><td>Output, Digital<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>NC = Not Connected<br><br>Area:<\/strong> 1 = Incoming Goods, 2 = Manufacturing, 3 = Outgoing Goods<\/p>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-15 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br><strong>I2C Address:<\/strong> <code>0x20<\/code><br>The MCP23018 uses the I2C address <code>0x20<\/code> in the FactoryBox. For more details, see<br><a href=\"#mcp23018-gpio-expander\">\ud83d\udd0c MCP23018 \u2013 GPIO Expander<\/a>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#factorybox\">\ud83e\uddf0 FactoryBox<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div style=\"height:2em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<h2 id=\"coding-information\" class=\"wp-block-heading\"><strong>Coding Information<\/strong><\/h2>\n\n\n\n<div style=\"height:2em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-11&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 id=\"platformio-ide\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-11-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-11\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\ud83e\uddd1\u200d\ud83d\udcbb PlatformIO IDE<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-11\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-11-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">This chapter walks you through using PlatformIO with Visual Studio Code to create, open, and manage projects for your ESP32.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#installing-platformio-in-vscode\" data-type=\"internal\" data-id=\"#installing-platformio-in-vscode\">Installing PlatformIO in VSCode<\/a><\/li>\n\n\n\n<li><a href=\"#create-a-new-project\">Create a New Project<\/a><\/li>\n\n\n\n<li><a href=\"#open-an-existing-platformio-project\">Open an Existing PlatformIO Project<\/a><\/li>\n\n\n\n<li><a href=\"#project-folder-structure\">Project Folder Structure<\/a><\/li>\n\n\n\n<li><a href=\"#-libraries\">Librarie<\/a><a href=\"#libraries\">s<\/a><\/li>\n\n\n\n<li><a href=\"#run-your-code\" data-type=\"internal\" data-id=\"#run-your-code\">Run Your Code<\/a><\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"overview\" class=\"wp-block-heading\"><strong>Overview<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/docs.platformio.org\/en\/latest\/what-is-platformio.html\">PlatformIO<\/a> is an open-source, cross-platform IDE specifically designed for embedded software development. It features built-in library management, extensive ESP32 support, and compatibility with the Arduino framework.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide uses PlatformIO with Visual Studio Code. While the provided code is generally compatible with the Arduino IDE, note there may be minor differences in project structure and library handling.<\/p>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-17 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udca1 <strong>Tip:<\/strong><br>Need more details on setting up or troubleshooting PlatformIO in VS Code? Check the official documentation:<br><a href=\"https:\/\/docs.platformio.org\/en\/latest\/integration\/ide\/vscode.html\"><strong>PlatformIO IDE for VS Code<\/strong><\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1024\" height=\"837\" data-attachment-id=\"402\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_home\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_home.png?fit=1207%2C987&amp;ssl=1\" data-orig-size=\"1207,987\" data-comments-opened=\"1\" data-image-title=\"pio_home\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_home.png?fit=1024%2C837&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_home.png?resize=1024%2C837&#038;ssl=1\" alt=\"\" class=\"wp-image-402\" title=\"PlatformIO Home\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_home.png?resize=1024%2C837&amp;ssl=1 1024w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_home.png?resize=300%2C245&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_home.png?resize=768%2C628&amp;ssl=1 768w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_home.png?w=1207&amp;ssl=1 1207w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"installing-platformio-in-vscode\" class=\"wp-block-heading\"><strong>Installing PlatformIO in VSCode<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click on Extension-Tab in the sidebar of Visual Studio <\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"342\" height=\"250\" data-attachment-id=\"1213\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/screenshot-2026-03-24-173038\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173038.png?fit=342%2C250&amp;ssl=1\" data-orig-size=\"342,250\" data-comments-opened=\"1\" data-image-title=\"Screenshot 2026-03-24 173038\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173038.png?fit=342%2C250&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173038.png?resize=342%2C250&#038;ssl=1\" alt=\"\" class=\"wp-image-1213\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173038.png?w=342&amp;ssl=1 342w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173038.png?resize=300%2C219&amp;ssl=1 300w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2. Search for &#8220;PlatformIO&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"222\" height=\"146\" data-attachment-id=\"1214\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/screenshot-2026-03-24-173059\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173059.png?fit=222%2C146&amp;ssl=1\" data-orig-size=\"222,146\" data-comments-opened=\"1\" data-image-title=\"Screenshot 2026-03-24 173059\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173059.png?fit=222%2C146&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173059.png?resize=222%2C146&#038;ssl=1\" alt=\"\" class=\"wp-image-1214\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3. Install the extension. You might need to restart VS Code after that.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"207\" height=\"44\" data-attachment-id=\"1215\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/screenshot-2026-03-24-173113\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173113.png?fit=207%2C44&amp;ssl=1\" data-orig-size=\"207,44\" data-comments-opened=\"1\" data-image-title=\"Screenshot 2026-03-24 173113\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173113.png?fit=207%2C44&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173113.png?resize=207%2C44&#038;ssl=1\" alt=\"\" class=\"wp-image-1215\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Contratulations \ud83c\udf89 You&#8217;re now ready to start working with PlatformIO. <br>You will find all the things you need for the following steps in the <strong>PIO Home-Tab<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1209\" height=\"704\" data-attachment-id=\"1216\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/screenshot-2026-03-24-173156\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173156.png?fit=1209%2C704&amp;ssl=1\" data-orig-size=\"1209,704\" data-comments-opened=\"1\" data-image-title=\"Screenshot 2026-03-24 173156\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173156.png?fit=1024%2C596&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173156.png?resize=1209%2C704&#038;ssl=1\" alt=\"\" class=\"wp-image-1216\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173156.png?w=1209&amp;ssl=1 1209w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173156.png?resize=300%2C175&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173156.png?resize=1024%2C596&amp;ssl=1 1024w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-173156.png?resize=768%2C447&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"create-a-new-project\" class=\"wp-block-heading\"><strong>Create a New Project<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">To get started, let&#8217;s create a new PlatformIO project for your ESP32 board:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open PlatformIO Home<\/li>\n\n\n\n<li>Click on &#8220;New Project&#8221;<\/li>\n\n\n\n<li>Choose a board: Type &#8220;esp32 dev&#8221; in the search bar and select &#8220;Espressif ESP32 Dev Module&#8221;<\/li>\n\n\n\n<li>Choose the Arduino framework (default)<\/li>\n\n\n\n<li>Choose a project location by unchecking &#8220;Use default location&#8221; and selecting a folder<\/li>\n\n\n\n<li>Click &#8220;Finish&#8221;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"595\" height=\"892\" data-attachment-id=\"405\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_project_new\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_new.png?fit=595%2C892&amp;ssl=1\" data-orig-size=\"595,892\" data-comments-opened=\"1\" data-image-title=\"pio_project_new\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_new.png?fit=595%2C892&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_new.png?resize=595%2C892&#038;ssl=1\" alt=\"\" class=\"wp-image-405\" title=\"PlatformIO - Home\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_new.png?w=595&amp;ssl=1 595w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_new.png?resize=200%2C300&amp;ssl=1 200w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once your project is created and opened, you&#8217;ll see its name appear in the bottom bar of VS Code (e.g., <code>Default (demo_project)<\/code>), confirming that your new project is active:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"938\" height=\"27\" data-attachment-id=\"400\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_bottom_bar_project\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?fit=938%2C27&amp;ssl=1\" data-orig-size=\"938,27\" data-comments-opened=\"1\" data-image-title=\"pio_bottom_bar_project\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?fit=938%2C27&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?resize=938%2C27&#038;ssl=1\" alt=\"\" class=\"wp-image-400\" title=\"PlatformIO - Bottom Bar Demo Project\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?w=938&amp;ssl=1 938w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?resize=300%2C9&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?resize=768%2C22&amp;ssl=1 768w\" sizes=\"(max-width: 938px) 100vw, 938px\" \/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#platformio-ide\">\ud83e\uddd1\u200d\ud83d\udcbb PlatformIO IDE<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"open-an-existing-platformio-project\" class=\"wp-block-heading\"><strong>Open an Existing PlatformIO Project<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Want to continue working on an existing project? Here&#8217;s how to open it in PlatformIO.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open PlatformIO Home<\/li>\n\n\n\n<li>Click on &#8220;Open Project&#8221;<\/li>\n\n\n\n<li>Select the project folder that contains the <strong>platformio.ini<\/strong> file<\/li>\n\n\n\n<li>Click &#8220;Open&#8221;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"588\" height=\"510\" data-attachment-id=\"406\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_project_open\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_open.png?fit=588%2C510&amp;ssl=1\" data-orig-size=\"588,510\" data-comments-opened=\"1\" data-image-title=\"pio_project_open\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_open.png?fit=588%2C510&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_open.png?resize=588%2C510&#038;ssl=1\" alt=\"\" class=\"wp-image-406\" title=\"PlatformIO - Open Existing Project\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_open.png?w=588&amp;ssl=1 588w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_project_open.png?resize=300%2C260&amp;ssl=1 300w\" sizes=\"(max-width: 588px) 100vw, 588px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When the project is loaded, its name will also appear in the bottom bar, just like with a newly created project:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"938\" height=\"27\" data-attachment-id=\"400\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_bottom_bar_project\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?fit=938%2C27&amp;ssl=1\" data-orig-size=\"938,27\" data-comments-opened=\"1\" data-image-title=\"pio_bottom_bar_project\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?fit=938%2C27&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?resize=938%2C27&#038;ssl=1\" alt=\"\" class=\"wp-image-400\" title=\"PlatformIO - Bottom Bar LED Project\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?w=938&amp;ssl=1 938w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?resize=300%2C9&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_project.png?resize=768%2C22&amp;ssl=1 768w\" sizes=\"(max-width: 938px) 100vw, 938px\" \/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#platformio-ide\">\ud83e\uddd1\u200d\ud83d\udcbb PlatformIO IDE<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"project-folder-structure\" class=\"wp-block-heading\"><strong>Project Folder Structure<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">When you create or open a PlatformIO project (e.g., <code>01_led_blink<\/code>), you&#8217;ll see a folder structure like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"118\" height=\"272\" data-attachment-id=\"401\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_folder_structure_expanded\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_folder_structure_expanded.png?fit=118%2C272&amp;ssl=1\" data-orig-size=\"118,272\" data-comments-opened=\"1\" data-image-title=\"pio_folder_structure_expanded\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_folder_structure_expanded.png?fit=118%2C272&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_folder_structure_expanded.png?resize=118%2C272&#038;ssl=1\" alt=\"\" class=\"wp-image-401\" title=\"PlatformIO Folder Structure\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s what each folder is for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>src\/<\/code><\/strong> \u2013 This is where your main code goes. Your entry point is <code>main.cpp<\/code><\/li>\n\n\n\n<li><strong><code>lib\/<\/code><\/strong> \u2013 Custom libraries you create for your project, or manually add (e.g. downloaded from GitHub)<\/li>\n\n\n\n<li><strong><code>include\/<\/code><\/strong> \u2013 Header files (.h) for declaring functions, constants, etc<\/li>\n\n\n\n<li><strong><code>.pio\/<\/code><\/strong> \u2013 PlatformIO uses this folder internally to store build output (<code>build\/<\/code>) and libraries installed via the library manager (<code>libdeps\/<\/code>)<\/li>\n\n\n\n<li><strong><code>platformio.ini<\/code><\/strong> \u2013 Your project&#8217;s configuration file (defines board type, libraries, build settings)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For your programs, focus on writing your code in <code>src\/main.cpp<\/code>.<br><br>PlatformIO automatically compiles and uploads the contents of that file to your ESP32.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#platformio-ide\">\ud83e\uddd1\u200d\ud83d\udcbb PlatformIO IDE<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"libraries\" class=\"wp-block-heading\"><strong>Libraries<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">PlatformIO uses a library manager to browse and install libraries. Libraries are installed per project, so you can have different libraries in different projects. They are listed in the <strong>platformio.ini<\/strong> file under the <code>lib_deps<\/code> line and are stored in the <code>.pio<\/code> folder within your project directory. If you no longer need a library, you can uninstall it through the library manager.<\/p>\n\n\n\n<h5 id=\"install-a-library\" class=\"wp-block-heading\"><strong>Install a Library:<\/strong><\/h5>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to PlatformIO<\/li>\n\n\n\n<li>Click on &#8220;Libraries&#8221;<\/li>\n\n\n\n<li>Open the &#8220;Registry&#8221; tab<\/li>\n\n\n\n<li>Search for the library you want to install<\/li>\n\n\n\n<li>Click on the library<\/li>\n\n\n\n<li>Click &#8220;Add to Project&#8221;<\/li>\n\n\n\n<li>Choose your project<\/li>\n\n\n\n<li>Click &#8220;Add&#8221;<\/li>\n<\/ol>\n\n\n\n<h5 id=\"uninstall-a-library\" class=\"wp-block-heading\"><strong>Uninstall a Library:<\/strong><\/h5>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to PlatformIO<\/li>\n\n\n\n<li>Click on &#8220;Libraries&#8221;<\/li>\n\n\n\n<li>Open the &#8220;Installed&#8221; tab<\/li>\n\n\n\n<li>Locate the library you want to uninstall (make sure you select the correct project)<\/li>\n\n\n\n<li>Click &#8220;Uninstall&#8221; and confirm with &#8220;Yes&#8221;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1024\" height=\"841\" data-attachment-id=\"403\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_lib\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib.png?fit=1200%2C985&amp;ssl=1\" data-orig-size=\"1200,985\" data-comments-opened=\"1\" data-image-title=\"pio_lib\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib.png?fit=1024%2C841&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib.png?resize=1024%2C841&#038;ssl=1\" alt=\"\" class=\"wp-image-403\" title=\"PlatformIO - Library\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib.png?resize=1024%2C841&amp;ssl=1 1024w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib.png?resize=300%2C246&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib.png?resize=768%2C630&amp;ssl=1 768w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib.png?w=1200&amp;ssl=1 1200w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In some cases, the version of a library in the PlatformIO Library Manager may be outdated, while a newer version is available on GitHub. If you want to use the GitHub version instead, you can add it manually to your project:<\/p>\n\n\n\n<h5 id=\"manually-install-a-library-from-github\" class=\"wp-block-heading\"><strong>Manually Install a Library from GitHub:<\/strong><\/h5>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Copy the GitHub repository URL of the library you want to use<\/li>\n\n\n\n<li>Open the <code>platformio.ini<\/code> file of your project<\/li>\n\n\n\n<li>Add the URL to the <code>lib_deps<\/code> line, for example: <code>lib_deps = https:\/\/github.com\/Seeed-Studio\/Grove_LED_Bar.git<\/code><\/li>\n\n\n\n<li>Save the file<\/li>\n\n\n\n<li>The library will be automatically downloaded and installed when you build or upload your code<\/li>\n\n\n\n<li>You can find the installed library inside the <code>lib<\/code> folder of your project<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"537\" height=\"291\" data-attachment-id=\"404\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_lib_manual\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib_manual.png?fit=537%2C291&amp;ssl=1\" data-orig-size=\"537,291\" data-comments-opened=\"1\" data-image-title=\"pio_lib_manual\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib_manual.png?fit=537%2C291&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib_manual.png?resize=537%2C291&#038;ssl=1\" alt=\"\" class=\"wp-image-404\" title=\"PlatformIO - Library .ini File\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib_manual.png?w=537&amp;ssl=1 537w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_lib_manual.png?resize=300%2C163&amp;ssl=1 300w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#platformio-ide\">\ud83e\uddd1\u200d\ud83d\udcbb PlatformIO IDE<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"run-your-code\" class=\"wp-block-heading\"><strong>Run Your Code<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once your code is ready, you can upload it to your ESP32 board:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Make sure the correct project is selected in the <strong>bottom bar<\/strong> (e.g., <code>Default (01_led_blink)<\/code>).<\/li>\n\n\n\n<li>Click the \u27a1\ufe0f <strong>Upload<\/strong> button (right arrow icon) in the bottom bar to build and flash your code to the ESP32.<\/li>\n\n\n\n<li>Optionally, you can click the \u2705 <strong>Build<\/strong> button first (checkmark icon) to compile the code without uploading \u2013 useful if you just want to check for errors.<\/li>\n\n\n\n<li>Open the <strong>Serial Monitor<\/strong> (plug icon) to view messages from <code>Serial.print()<\/code> and other serial output.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"925\" height=\"30\" data-attachment-id=\"399\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/pio_bottom_bar_led_upload\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_led_upload.png?fit=925%2C30&amp;ssl=1\" data-orig-size=\"925,30\" data-comments-opened=\"1\" data-image-title=\"pio_bottom_bar_led_upload\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_led_upload.png?fit=925%2C30&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_led_upload.png?resize=925%2C30&#038;ssl=1\" alt=\"\" class=\"wp-image-399\" title=\"PlatformIO - Bottom Bar LED Project\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_led_upload.png?w=925&amp;ssl=1 925w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_led_upload.png?resize=300%2C10&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/02\/pio_bottom_bar_led_upload.png?resize=768%2C25&amp;ssl=1 768w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure your board is connected via USB and the correct COM port is selected (PlatformIO usually detects this automatically).<\/p>\n\n\n\n<p class=\"has-custom-orange-background-color has-background wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">If your ESP doesn&#8217;t connect\/respond while uploading<strong> press the BOOT-Button<\/strong> until you see &#8220;<em>Connecting<\/em>&#8221; on the terminal<br>If the error code reads &#8220;<em>COM3 does not exist<\/em>&#8220;, just <strong>unplug the USB-C cable<\/strong> on your laptop for a second.<\/p>\n\n\n\n<p class=\"has-base-color has-custom-aalen-purple-background-color has-text-color has-background has-link-color wp-elements-18 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">If you don&#8217;t see any messages in the <strong>Serial Monitor<\/strong>, double-check that you&#8217;ve included <code>Serial.begin(baud-rate);<\/code> in your <code>setup()<\/code> function, and ensure the baud rate (e.g., 9600) matches the one selected in your Serial Monitor settings.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#platformio-ide\">\ud83e\uddd1\u200d\ud83d\udcbb PlatformIO IDE<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-12&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-12-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-12\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\u2733\ufe0fArduino IDE <\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-12\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-12-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wp-block-paragraph\">This chapter is designed to assist you, should you not use PlatformIO as an IDE.<br>It briefly shows the basics with the ArduinoIDE.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is recommend to look up more detailed instruction when necessary.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"important\" class=\"wp-block-heading\">\u2757IMPORTANT<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You <strong>cannot <\/strong>use the example codes directly, as they are created for PlatformIO.<br>However, in the seperate example folders, you will find the code in the <em>scr-folder<\/em> in the <em>main.cpp<\/em> file.<br>You can directly copy the code in there, into the <em>.ino<\/em> file in a new arduino project.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"installing-esp32-dependencies-from-boardmanager\" class=\"wp-block-heading\">Installing ESP32 Dependencies from Boardmanager<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Open the Board Manager over <em>Tools&gt; Board&gt; Boardmanager<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the ESP32 is not already installed, search for esp32 by espressiv and install it.<br>Select the DOIT DEVKIT V1 Version <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"719\" height=\"602\" data-attachment-id=\"1766\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/screenshot-2026-07-16-231520\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-231520.png?fit=719%2C602&amp;ssl=1\" data-orig-size=\"719,602\" data-comments-opened=\"1\" data-image-title=\"Screenshot 2026-07-16 231520\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-231520.png?fit=719%2C602&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-231520.png?resize=719%2C602&#038;ssl=1\" alt=\"\" class=\"wp-image-1766\" style=\"width:537px;height:auto\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-231520.png?w=719&amp;ssl=1 719w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-231520.png?resize=300%2C251&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-231520.png?resize=14%2C12&amp;ssl=1 14w\" sizes=\"(max-width: 719px) 100vw, 719px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"375\" height=\"340\" data-attachment-id=\"1779\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/grafik-6\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-4.png?fit=375%2C340&amp;ssl=1\" data-orig-size=\"375,340\" data-comments-opened=\"1\" data-image-title=\"grafik\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-4.png?fit=375%2C340&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-4.png?resize=375%2C340&#038;ssl=1\" alt=\"\" class=\"wp-image-1779\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-4.png?w=375&amp;ssl=1 375w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-4.png?resize=300%2C272&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-4.png?resize=13%2C12&amp;ssl=1 13w\" sizes=\"(max-width: 375px) 100vw, 375px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"create-a-new-project-1\" class=\"wp-block-heading\">Create a new Project<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"229\" height=\"93\" data-attachment-id=\"1772\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/grafik-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik.png?fit=229%2C93&amp;ssl=1\" data-orig-size=\"229,93\" data-comments-opened=\"1\" data-image-title=\"grafik\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik.png?fit=229%2C93&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik.png?resize=229%2C93&#038;ssl=1\" alt=\"\" class=\"wp-image-1772\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik.png?w=229&amp;ssl=1 229w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik.png?resize=18%2C7&amp;ssl=1 18w\" sizes=\"(max-width: 229px) 100vw, 229px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"open-existing-project\" class=\"wp-block-heading\">Open existing Project<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"220\" height=\"174\" data-attachment-id=\"1776\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/grafik-4\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-2.png?fit=220%2C174&amp;ssl=1\" data-orig-size=\"220,174\" data-comments-opened=\"1\" data-image-title=\"grafik\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-2.png?fit=220%2C174&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-2.png?resize=220%2C174&#038;ssl=1\" alt=\"\" class=\"wp-image-1776\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-2.png?w=220&amp;ssl=1 220w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-2.png?resize=15%2C12&amp;ssl=1 15w\" sizes=\"(max-width: 220px) 100vw, 220px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"folder-structure-or-lack-thereof\" class=\"wp-block-heading\">Folder structure (or lack thereof)<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">In Arduino V2 you can set a sketchbook location, where the program is able to find existing code to open.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, it does not work with subfolders<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"759\" height=\"132\" data-attachment-id=\"1773\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/grafik-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-1.png?fit=759%2C132&amp;ssl=1\" data-orig-size=\"759,132\" data-comments-opened=\"1\" data-image-title=\"grafik\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-1.png?fit=759%2C132&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-1.png?resize=759%2C132&#038;ssl=1\" alt=\"\" class=\"wp-image-1773\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-1.png?w=759&amp;ssl=1 759w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-1.png?resize=300%2C52&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-1.png?resize=18%2C3&amp;ssl=1 18w\" sizes=\"(max-width: 759px) 100vw, 759px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"364\" height=\"276\" data-attachment-id=\"1775\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/screenshot-2026-07-16-232606-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232606-edited.png?fit=364%2C276&amp;ssl=1\" data-orig-size=\"364,276\" data-comments-opened=\"1\" data-image-title=\"Screenshot 2026-07-16 232606\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232606-edited.png?fit=364%2C276&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232606-edited.png?resize=364%2C276&#038;ssl=1\" alt=\"\" class=\"wp-image-1775\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232606-edited.png?w=364&amp;ssl=1 364w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232606-edited.png?resize=300%2C227&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232606-edited.png?resize=16%2C12&amp;ssl=1 16w\" sizes=\"(max-width: 364px) 100vw, 364px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"libraries-1\" class=\"wp-block-heading\">Libraries<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"354\" height=\"312\" data-attachment-id=\"1784\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/grafik-8\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-5-edited.png?fit=354%2C312&amp;ssl=1\" data-orig-size=\"354,312\" data-comments-opened=\"1\" data-image-title=\"grafik\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-5-edited.png?fit=354%2C312&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-5-edited.png?resize=354%2C312&#038;ssl=1\" alt=\"\" class=\"wp-image-1784\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-5-edited.png?w=354&amp;ssl=1 354w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-5-edited.png?resize=300%2C264&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-5-edited.png?resize=14%2C12&amp;ssl=1 14w\" sizes=\"(max-width: 354px) 100vw, 354px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"473\" height=\"165\" data-attachment-id=\"1785\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/grafik-9\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-6.png?fit=473%2C165&amp;ssl=1\" data-orig-size=\"473,165\" data-comments-opened=\"1\" data-image-title=\"grafik\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-6.png?fit=473%2C165&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-6.png?resize=473%2C165&#038;ssl=1\" alt=\"\" class=\"wp-image-1785\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-6.png?w=473&amp;ssl=1 473w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-6.png?resize=300%2C105&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/grafik-6.png?resize=18%2C6&amp;ssl=1 18w\" sizes=\"(max-width: 473px) 100vw, 473px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"run-your-code-1\" class=\"wp-block-heading\">Run your code<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can compile your code with the first button on the top-left<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">if you want to compile and upload it, choose the second button, as shown.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Always make sure the correct board is selected.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"436\" height=\"55\" data-attachment-id=\"1769\" data-permalink=\"https:\/\/learningfactorybox.com\/de\/teaching-material\/screenshot-2026-07-16-232056\/\" data-orig-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232056.png?fit=436%2C55&amp;ssl=1\" data-orig-size=\"436,55\" data-comments-opened=\"1\" data-image-title=\"Screenshot 2026-07-16 232056\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232056.png?fit=436%2C55&amp;ssl=1\" fetchpriority=\"low\" src=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232056.png?resize=436%2C55&#038;ssl=1\" alt=\"\" class=\"wp-image-1769\" srcset=\"https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232056.png?w=436&amp;ssl=1 436w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232056.png?resize=300%2C38&amp;ssl=1 300w, https:\/\/i0.wp.com\/learningfactorybox.com\/wp-content\/uploads\/2026\/07\/Screenshot-2026-07-16-232056.png?resize=18%2C2&amp;ssl=1 18w\" sizes=\"(max-width: 436px) 100vw, 436px\" \/><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-13&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 id=\"arduino-code-structure\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-13-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-13\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\ud83e\udde9 Arduino Code Structure<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-13\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-13-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">A typical Arduino sketch consists of three main parts:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"#libraries-and-definitions\" data-type=\"internal\" data-id=\"#libraries-and-definitions\">Libraries and Definitions<\/a><\/li>\n\n\n\n<li><a href=\"#the-setup-code\">The Setup Code<\/a><\/li>\n\n\n\n<li><a href=\"#the-loop-code\" data-type=\"internal\" data-id=\"#the-loop-code\">The Loop Code<\/a><\/li>\n<\/ol>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-comment\">\/* <\/span><\/div><div class=\"cm-line\"><span class=\"tok-comment\">     1. Include libraries, define constants, declare global variables, etc.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-comment\">*\/<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-typeName\">void<\/span> <span class=\"tok-variableName tok-definition\">setup<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-comment\">\/\/ 2. This function runs once when the device starts or resets.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-typeName\">void<\/span> <span class=\"tok-variableName tok-definition\">loop<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-comment\">\/\/ 3. This function runs repeatedly after setup() and contains your main code.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"has-custom-aalen-blue-new-background-color has-background wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br>When using PlatformIO, you must include the <code>Arduino.h<\/code> library to access standard Arduino functions (this is not required in the Arduino IDE).<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<h4 id=\"what-is-arduino\" class=\"wp-block-heading\">What is Arduino?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Arduino is a open source platform that makes coding easy. And it&#8217;s crossplattform! \ud83c\udf89<br>Since the language it&#8217;s based on C\/C++ you can not only build simple projects with it. You can include .h, .cpp files and build your project to insane sizes &#8211; if you dare \ud83d\ude09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But there are also multiple micro-controllers in the Arduino Family that you can programm. They are comaptible with most sensors and due to their popularity, the open-source community behind is is thriving and offering many ressoruces for nearly all problems, no matter how tricky.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But it is also compatible with other microcontrollers like the ESP32 .<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To learn more about the history of Arduino go <a href=\"https:\/\/docs.arduino.cc\/learn\/starting-guide\/whats-arduino\/\">here<\/a> or watch an <a href=\"https:\/\/www.youtube.com\/watch?v=CSx6k-zXlLE\">introductory video<\/a> \ud83d\ude43<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<h4 id=\"libraries-and-definitions\" class=\"wp-block-heading\"><strong>Libraries and Definitions<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Start by including all necessary libraries and defining global constants, variables, and objects. This section is where you set up anything that will be used throughout your program.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-meta\">#include<\/span> <span class=\"tok-string2\">&lt;Arduino.h&gt;<\/span>  <span class=\"tok-comment\">\/\/ Essential for PlatformIO projects (Arduino IDE automatically includes this).<\/span><\/div><div class=\"cm-line\"><span class=\"tok-meta\">#include<\/span> <span class=\"tok-string2\">&lt;ExampleLibrary.h&gt;<\/span>  <span class=\"tok-comment\">\/\/ Replace with the libraries you need<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ Define constants for hardware connections. These values should not change.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-keyword\">const<\/span> <span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">LED_PIN<\/span> = <span class=\"tok-number\">23<\/span>;  <span class=\"tok-comment\">\/\/ Example: assign the LED to GPIO pin 23<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ Declare global variables that can change during program execution.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">exampleVariable<\/span> = <span class=\"tok-operator\">-<\/span><span class=\"tok-number\">1<\/span>;  <span class=\"tok-comment\">\/\/ Example variable initialized to -1<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#arduino-code-structure\">\ud83e\udde9 Arduino Code Structure<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<h4 id=\"the-setup-code\" class=\"wp-block-heading\"><strong>The Setup Code<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>setup()<\/code> function is executed once when the ESP32 (or any Arduino board) starts or resets. Use this function to initialize serial communication, configure pin modes, and set initial states for variables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-typeName\">void<\/span> <span class=\"tok-variableName tok-definition\">setup<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">begin<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">9600<\/span><span class=\"tok-punctuation\">)<\/span>;          <span class=\"tok-comment\">\/\/ Initialize serial communication at 9600 baud for debugging.<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-string\">&quot;LED Blink&quot;<\/span><span class=\"tok-punctuation\">)<\/span>; <span class=\"tok-comment\">\/\/ Output an initial message to the Serial Monitor.<\/span><\/div><div class=\"cm-line\">  <\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">pinMode<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">OUTPUT<\/span><span class=\"tok-punctuation\">)<\/span>;    <span class=\"tok-comment\">\/\/ Configure the LED pin as an output.<\/span><\/div><div class=\"cm-line\">  <\/div><div class=\"cm-line\">  <span class=\"tok-comment\">\/\/ Additional setup code (e.g., sensor initialization) can be added here.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#arduino-code-structure\">\ud83e\udde9 Arduino Code Structure<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div style=\"height:1rem\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-f8977727\"\/>\n\n\n\n<div style=\"height:1rem\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<h4 id=\"the-loop-code\" class=\"wp-block-heading\"><strong>The Loop Code<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>loop()<\/code> function runs continuously after <code>setup()<\/code> finishes. It contains the main logic of your program and will repeat until the board is powered off or reset.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-typeName\">void<\/span> <span class=\"tok-variableName tok-definition\">loop<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-comment\">\/\/ Turn the LED on, print a message, and wait.<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">HIGH<\/span><span class=\"tok-punctuation\">)<\/span>;   <span class=\"tok-comment\">\/\/ Activate the LED.<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-string\">&quot;LED ON&quot;<\/span><span class=\"tok-punctuation\">)<\/span>;      <span class=\"tok-comment\">\/\/ Output current status to the Serial Monitor.<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">delay<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">1000<\/span><span class=\"tok-punctuation\">)<\/span>;                   <span class=\"tok-comment\">\/\/ Wait for 1 second (1000 milliseconds).<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\">  <span class=\"tok-comment\">\/\/ Turn the LED off, print a message, and wait.<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">LOW<\/span><span class=\"tok-punctuation\">)<\/span>;    <span class=\"tok-comment\">\/\/ Deactivate the LED.<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-string\">&quot;LED OFF&quot;<\/span><span class=\"tok-punctuation\">)<\/span>;     <span class=\"tok-comment\">\/\/ Output current status to the Serial Monitor.<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">delay<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">1000<\/span><span class=\"tok-punctuation\">)<\/span>;                   <span class=\"tok-comment\">\/\/ Wait for 1 second.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">This structure helps keep your code organized, making it easier to manage and expand your projects.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#arduino-code-structure\" data-type=\"internal\" data-id=\"#arduino-code-structure\">\ud83e\udde9 Arduino Code Structure<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-14&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 id=\"common-functions-you-ll-use\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-14-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-14\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\ud83d\udca1 Common Functions You&#8217;ll Use<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-14\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-14-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">This section covers the <strong>most common functions<\/strong> you&#8217;ll use regularly in your ESP32 projects:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#pin-configuration\">Pin Configuration<\/a><\/li>\n\n\n\n<li><a href=\"#serial-communication\">Serial Communication<\/a><\/li>\n\n\n\n<li><a href=\"#readwrite-data\">Read\/Write Data<\/a><\/li>\n\n\n\n<li><a href=\"#\ufe0ftiming-and-logic\" data-type=\"internal\" data-id=\"#\ufe0ftiming-and-logic\">Timing and Logic<\/a><\/li>\n\n\n\n<li><a href=\"#\ufe0futility-functions\" data-type=\"internal\" data-id=\"#\ufe0futility-functions\">Utility Functions<\/a><\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"pin-configuration\" class=\"wp-block-heading\"><strong>Pin Configuration<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Learn how to define pins and configure them correctly for input and output:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Define a Pin<\/strong>\n<ul class=\"wp-block-list\">\n<li>Create a named constant for a pin to make your code more readable and easier to maintain.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-keyword\">const<\/span> <span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">LED_PIN<\/span> = <span class=\"tok-number\">2<\/span>;  <span class=\"tok-comment\">\/\/ Replace 2 with the actual GPIO pin number you want to use<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/digital-io\/pinMode\/\"><strong>pinMode(pin, mode)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Configures a specified pin to behave as either an input or an output.<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-variableName\">pinMode<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">OUTPUT<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-variableName\">pinMode<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">SENSOR_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">INPUT<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-variableName\">pinMode<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">BUTTON_PIN_1<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">INPUT_PULLDOWN<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-variableName\">pinMode<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">BUTTON_PIN_2<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">INPUT_PULLUP<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-19 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br>Not sure which GPIO pin number to use?<br>See <a href=\"#gpio-pinout\">GPIO Pinout<\/a> to find all pin assignments for the ESP32 and<br>MCP23018 in your FactoryBox.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#common-functions-you-ll-use\">\ud83d\udca1 Common Functions You&#8217;ll Use<\/a> \u00b7 <a href=\"#toc\" data-type=\"internal\" data-id=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"serial-communication\" class=\"wp-block-heading\"><strong>Serial Communication<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Easily debug your code by printing messages to the Serial Monitor:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Serial communication allows you to send data to the Serial Monitor for debugging or logging purposes. Below are the most commonly used functions and when to use them:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"http:\/\/docs.arduino.cc\/language-reference\/en\/functions\/communication\/serial\/begin\/\"><strong>Serial.begin(baudRate)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li><strong>Required!<\/strong> This function must be called once in the <code>setup()<\/code> function to initialize serial communication.<\/li>\n\n\n\n<li>If you don&#8217;t call <code>Serial.begin()<\/code>, none of the other serial functions (<code>print<\/code>, <code>println<\/code>, <code>printf<\/code>) will work \u2013 you won&#8217;t see any output in the Serial Monitor.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">begin<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">9600<\/span><span class=\"tok-punctuation\">)<\/span>;  <span class=\"tok-comment\">\/\/ Initialize serial communication at 9600 baud<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/communication\/serial\/print\/\"><strong>Serial.print(data)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Sends data as human-readable ASCII text without a newline at the end.<\/li>\n\n\n\n<li><strong>Memory Note:<\/strong> Literal strings not wrapped in the <code>F()<\/code> macro are stored in <strong>RAM<\/strong>. Use <code>F(\"string\")<\/code> to store strings in <strong>Flash memory<\/strong> and save RAM.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-typeName\">float<\/span> <span class=\"tok-variableName\">temperature<\/span> = <span class=\"tok-number\">23.456<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">humidity<\/span> = <span class=\"tok-number\">45<\/span>;<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">print<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-string\">&quot;Hello, world!&quot;<\/span><span class=\"tok-punctuation\">)<\/span>;    <span class=\"tok-comment\">\/\/ Prints a string from SRAM<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">print<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">F<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-string\">&quot;Hello, Flash!&quot;<\/span><span class=\"tok-punctuation\">)<\/span><span class=\"tok-punctuation\">)<\/span>; <span class=\"tok-comment\">\/\/ Prints a string from Flash memory<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">print<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">temperature<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">2<\/span><span class=\"tok-punctuation\">)<\/span>;     <span class=\"tok-comment\">\/\/ Prints a variable with 2 decimal places<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">print<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">humidity<\/span><span class=\"tok-punctuation\">)<\/span>;           <span class=\"tok-comment\">\/\/ Prints a variable<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code><div class=\"cm-line\">Hello, world!Hello, Flash!23.4645<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/communication\/serial\/println\/\"><strong>Serial.println(data)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Similar to <code>Serial.print()<\/code>, but appends a carriage return and newline (<code>\\r\\n<\/code>) so that the next output begins on a new line.<\/li>\n\n\n\n<li><strong>Memory Note:<\/strong> As with <code>Serial.print()<\/code>, use <code>F()<\/code> to move constant strings to Flash memory and save RAM.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-typeName\">float<\/span> <span class=\"tok-variableName\">temperature<\/span> = <span class=\"tok-number\">23.456<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">humidity<\/span> = <span class=\"tok-number\">45<\/span>;<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-string\">&quot;Hello, world!&quot;<\/span><span class=\"tok-punctuation\">)<\/span>;      <span class=\"tok-comment\">\/\/ Prints the string and moves to a new line<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">F<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-string\">&quot;Hello, Flash!&quot;<\/span><span class=\"tok-punctuation\">)<\/span><span class=\"tok-punctuation\">)<\/span>;   <span class=\"tok-comment\">\/\/ Prints string stored in Flash and moves to a new line<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-punctuation\">)<\/span>;                     <span class=\"tok-comment\">\/\/ Prints a blank line and moves to a new line<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">temperature<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">2<\/span><span class=\"tok-punctuation\">)<\/span>;       <span class=\"tok-comment\">\/\/ Prints a variable with 2 decimal places and moves to a new line<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">humidity<\/span><span class=\"tok-punctuation\">)<\/span>;             <span class=\"tok-comment\">\/\/ Prints a variable and moves to a new line<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code><div class=\"cm-line\">Hello, world!<\/div><div class=\"cm-line\">Hello, Flash!<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\">23.46<\/div><div class=\"cm-line\">45<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#-common-functions-youll-use\">\ud83d\udca1 <\/a><a href=\"#cocommon-functions-you-ll-use\">Common Functions You&#8217;ll Use<\/a> \u00b7 <a href=\"#-table-of-contents\">\ud83d\udcd1 <\/a><a href=\"#toc\" data-type=\"internal\" data-id=\"#toc\">Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"read-write-data\" class=\"wp-block-heading\"><strong>Read\/Write Data<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Discover how to interact with sensors, buttons, LEDs, and more:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/digital-io\/digitalwrite\/\"><strong>digitalWrite(pin, value)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Writes a <code>HIGH<\/code> or <code>LOW<\/code> value to a digital pin.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">HIGH<\/span><span class=\"tok-punctuation\">)<\/span>;  <span class=\"tok-comment\">\/\/ Turn the LED on<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">LOW<\/span><span class=\"tok-punctuation\">)<\/span>;   <span class=\"tok-comment\">\/\/ Turn the LED off<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/digital-io\/digitalread\/\"><strong>digitalRead(pin)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Reads the value (<code>HIGH<\/code> or <code>LOW<\/code>) from a specified digital pin.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">buttonState<\/span> = <span class=\"tok-variableName\">digitalRead<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">BUTTON_PIN<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">sensorReading<\/span> = <span class=\"tok-variableName\">digitalRead<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">SENSOR_PIN<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/analog-io\/analogWrite\/\"><strong>analogWrite(pin, value)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Writes an analog (PWM) value to a pin. On most boards, the default resolution is 8-bit (0 to 255).<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-variableName\">analogWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">180<\/span><span class=\"tok-punctuation\">)<\/span>;  <span class=\"tok-comment\">\/\/ Set LED brightness (0 = off, 255 = full brightness)<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/analog-io\/analogRead\/\"><strong>analogRead(pin)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Reads the value from an analog pin. ESP32 analog inputs have a 12-bit resolution (0 to 4095).<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">sensorReading<\/span> = <span class=\"tok-variableName\">analogRead<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">SENSOR_PIN<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#-common-functions-youll-use\">\ud83d\udca1<\/a><a href=\"#common-functions-you-ll-use\" data-type=\"internal\" data-id=\"#common-functions-you-ll-use\"> Common Functions You&#8217;ll Use<\/a> \u00b7 <a href=\"#-table-of-contents\">\ud83d\udcd1 <\/a><a href=\"#toc\" data-type=\"internal\" data-id=\"#toc\">Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"timing-and-logic\" class=\"wp-block-heading\"><strong>Timing and Logic<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Essential tools to control the flow and timing of your program:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/time\/delay\/\"><strong>delay(milliseconds)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Pauses the program for a set amount of time. Useful for blinking LEDs, debouncing buttons, and slowing down actions.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">HIGH<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-variableName\">delay<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">500<\/span><span class=\"tok-punctuation\">)<\/span>;  <span class=\"tok-comment\">\/\/ Wait 500 milliseconds (code execution is paused)<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">LOW<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-variableName\">delay<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">500<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-20 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br>While <strong><code>delay()<\/code><\/strong> is simple and useful, it <strong>blocks your program<\/strong> \u2013 meaning no other code runs during the wait.<br>If you <strong>need to do multiple things at once<\/strong> (like blinking an LED while checking a button),<br><strong><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/time\/millis\/\">consider the non-blocking <code>millis()<\/code> approach instead<\/a><\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/structure\/control-structure\/if\/\"><strong>if<\/strong>\ud83d\udd17<\/a> \/ <a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/structure\/control-structure\/else\/\"><strong>else<\/strong>\ud83d\udd17<\/a> Statement (Conditional Statement)\n<ul class=\"wp-block-list\">\n<li>Control the flow of your program based on conditions. Perfect for checking sensor values, buttons, or states.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-keyword\">if<\/span> <span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">buttonState<\/span> <span class=\"tok-operator\">==<\/span> <span class=\"tok-variableName\">HIGH<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">HIGH<\/span><span class=\"tok-punctuation\">)<\/span>;  <span class=\"tok-comment\">\/\/ LED on<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span> <span class=\"tok-keyword\">else<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">LOW<\/span><span class=\"tok-punctuation\">)<\/span>;   <span class=\"tok-comment\">\/\/ LED off<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/structure\/control-structure\/for\/\"><strong>for<\/strong> Loop\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Use a <code>for<\/code> loop when you want to repeat something a specific number of times or iterate over a range of values.<\/li>\n\n\n\n<li><strong>General Syntax:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-keyword\">for<\/span> <span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">initialization<\/span>; <span class=\"tok-variableName\">condition<\/span>; <span class=\"tok-variableName\">increment<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-comment\">\/\/ statement(s);<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ A for-loop starts with an initialization, executed once.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ Then the condition is evaluated \u2013 if true, the loop body runs.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ After each run, the increment step is executed.<\/span><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ This repeats until the condition becomes false, and the loop ends.<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ Blink an LED 5 times<\/span><\/div><div class=\"cm-line\"><span class=\"tok-keyword\">for<\/span> <span class=\"tok-punctuation\">(<\/span><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">i<\/span> = <span class=\"tok-number\">0<\/span>; <span class=\"tok-variableName\">i<\/span> <span class=\"tok-operator\">&lt;<\/span> <span class=\"tok-number\">5<\/span>; <span class=\"tok-variableName\">i<\/span><span class=\"tok-operator\">++<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">HIGH<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">delay<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">500<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">LOW<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">delay<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">500<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ Count from 0 to 4 and print the numbers<\/span><\/div><div class=\"cm-line\"><span class=\"tok-keyword\">for<\/span> <span class=\"tok-punctuation\">(<\/span><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">i<\/span> = <span class=\"tok-number\">0<\/span>; <span class=\"tok-variableName\">i<\/span> <span class=\"tok-operator\">&lt;<\/span> <span class=\"tok-number\">5<\/span>; <span class=\"tok-variableName\">i<\/span><span class=\"tok-operator\">++<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">Serial<\/span>.<span class=\"tok-propertyName\">println<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">i<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ Loop explanation:<\/span><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ int i = 0: Initializes the loop counter i<\/span><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ i &lt; 5: The loop runs while this condition is true<\/span><\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ i++: Increments i by 1 after each loop cycle<\/span><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#common-functions-youll-use\">\ud83d\udca1 Common Functions You&#8217;ll Use<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 id=\"utility-functions\" class=\"wp-block-heading\"><strong>Utility Functions<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Helpful built-in functions to simplify common tasks in your code:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/math\/map\/\"><strong>map(value, fromLow, fromHigh, toLow, toHigh)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Maps a number from one range to another.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">ledValue<\/span> = <span class=\"tok-variableName\">map<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">potiRead<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">0<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">4095<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">0<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">255<\/span><span class=\"tok-punctuation\">)<\/span>;<\/div><div class=\"cm-line\"><span class=\"tok-comment\">\/\/ Maps the potentiometer value (0 to 4095, 12-bit) to the analogWrite range (0 to 255, 8-bit PWM)<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/en\/functions\/math\/constrain\/\"><strong>constrain(value, min, max)<\/strong>\ud83d\udd17<\/a>\n<ul class=\"wp-block-list\">\n<li>Constrains a value to a specified range.<\/li>\n\n\n\n<li><strong>Example:<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">constrainedValue<\/span> = <span class=\"tok-variableName\">constrain<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">sensorValue<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">1000<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-number\">3000<\/span><span class=\"tok-punctuation\">)<\/span>;  <span class=\"tok-comment\">\/\/ Limits the value between 1000 and 3000<\/span><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#common-functions-youll-use\">\ud83d\udca1 Common Functions You&#8217;ll Use<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-15&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 id=\"examples-your-starting-point\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-15-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-15\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\ud83d\ude80 Examples \u2013 Your Starting Point<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-15\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-15-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">Not sure where to start? Explore the <a href=\"#examples\">examples<\/a> in the downloadable folder. Each example demonstrates how to use a specific component of your FactoryBox \u2013 perfect starting points for your own projects.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Try uploading one of these ready-made examples directly to your board and see immediate results!<br><br>If the example requires you to install additional libraries, these will be clearly mentioned in comments within the code.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity has-custom-css wp-custom-css-09782953\"\/>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<h4 id=\"blink-an-led-your-first-example\" class=\"wp-block-heading\">Blink an LED \u2013 Your First Example<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start by blinking an LED \u2013 the &#8220;Hello World&#8221; of hardware programming:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-c++\"><div class=\"cm-line\"><span class=\"tok-meta\">#include<\/span> <span class=\"tok-string2\">&lt;Arduino.h&gt;<\/span>                <span class=\"tok-comment\">\/\/ include Arduino library<\/span><\/div><div class=\"cm-line\"><span class=\"tok-keyword\">const<\/span> <span class=\"tok-typeName\">int<\/span> <span class=\"tok-variableName\">LED_PIN<\/span> = <span class=\"tok-number\">23<\/span>;             <span class=\"tok-comment\">\/\/ the number of the LED GPIO pin<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-typeName\">void<\/span> <span class=\"tok-variableName tok-definition\">setup<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">pinMode<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">OUTPUT<\/span><span class=\"tok-punctuation\">)<\/span>;         <span class=\"tok-comment\">\/\/ initialize the LED pin as an output<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-typeName\">void<\/span> <span class=\"tok-variableName tok-definition\">loop<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-punctuation\">)<\/span> <span class=\"tok-punctuation\">{<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">HIGH<\/span><span class=\"tok-punctuation\">)<\/span>;      <span class=\"tok-comment\">\/\/ turn the LED on<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">delay<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">1000<\/span><span class=\"tok-punctuation\">)<\/span>;                       <span class=\"tok-comment\">\/\/ wait for 500 milliseconds<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">digitalWrite<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-variableName\">LED_PIN<\/span><span class=\"tok-punctuation\">,<\/span> <span class=\"tok-variableName\">LOW<\/span><span class=\"tok-punctuation\">)<\/span>;       <span class=\"tok-comment\">\/\/ turn the LED off<\/span><\/div><div class=\"cm-line\">  <span class=\"tok-variableName\">delay<\/span><span class=\"tok-punctuation\">(<\/span><span class=\"tok-number\">1000<\/span><span class=\"tok-punctuation\">)<\/span>;                       <span class=\"tok-comment\">\/\/ wait for 500 milliseconds<\/span><\/div><div class=\"cm-line\"><span class=\"tok-punctuation\">}<\/span><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<ol class=\"wp-block-list\">\n<li>Create a new PlatformIO project (<a href=\"#platformio-ide\" data-type=\"internal\" data-id=\"#platformio-ide\">as explained above<\/a>)<\/li>\n\n\n\n<li>Copy and paste this code into your main.cpp<\/li>\n\n\n\n<li>Upload it<\/li>\n\n\n\n<li>Watch the LED blink every second!<\/li>\n<\/ol>\n\n\n\n<p class=\"has-custom-aalen-purple-color has-custom-aalen-blue-new-background-color has-text-color has-background has-link-color wp-elements-21 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">\ud83d\udcdd <strong>Note:<\/strong><br><strong>Need to find the right GPIO pin for your component?<\/strong><br>The <a href=\"#gpio-pinout\">GPIO Pinout<\/a> shows all pins for the ESP32 and MCP23018 in the FactoryBox.<\/p>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: false, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-16&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 id=\"debugging\" class=\"wp-block-accordion-heading\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-16-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" id=\"accordion-item-16\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-title\">\u2620\ufe0f Debugging (Finding what is wrong with your code)<\/span><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><\/button><\/h3>\n\n\n\n<div aria-labelledby=\"accordion-item-16\" data-wp-bind--hidden=\"state.isHidden\" data-wp-on--beforematch=\"actions.handleBeforeMatch\" id=\"accordion-item-16-panel\" role=\"region\" class=\"wp-block-accordion-panel is-layout-flow wp-block-accordion-panel-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">If it&#8217;s just a small problem &#8211; use print statements.<br>If you want to understand if the code ever enters a statement. If you want to see if a variable actually changes value&#8230;.<br>Add an output at the affected line.<br>Since Arduino is an interpreter based language, it will process each line seperately and just fail at the error.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To learn how to really debug with VSCode go <a href=\"https:\/\/code.visualstudio.com\/docs\/debugtest\/debugging\">here<\/a>.<\/p>\n\n\n\n<p class=\"has-custom-uo-a-yellow-color has-custom-aalen-dark-pink-background-color has-text-color has-background has-link-color wp-elements-22 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">A simple <em style=\"color:#FFFFFF;\">Serial.println(&#8220;debugging message here&#8221;)<\/em> works wonders if you want to see if the code has passed a condition or line of code.<\/p>\n\n\n\n<div style=\"height:1em\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<h3 id=\"further-learning\" class=\"wp-block-heading\">\ud83d\udcd6 Further Learning<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Want to learn more? Need more detail?<br>Here are some official Arduino resources to help you learn more about programming, syntax, and best practices:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/\"><strong>The Official Arduino Documentation<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Useful sections:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.arduino.cc\/programming\/\"><strong>Programming with Arduino<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/#functions\"><strong>Functions<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/#variables\"><strong>Data Types and Constants<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.arduino.cc\/language-reference\/#structure\"><strong>The Elements of Arduino (C++) Code<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The arduino coding community is big and most probably other people have faced the problems you&#8217;re dealing with.<br>Help is only one google search away.<\/p>\n\n\n\n<p class=\"has-base-color has-custom-aalen-dark-pink-background-color has-text-color has-background has-link-color wp-elements-23 wp-block-paragraph\" style=\"border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px\">Most importantly &#8211; have fun \ud83d\ude09<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udd17 Jump to: <a href=\"#-common-functions-youll-use\">\ud83d\udca1 <\/a><a href=\"#common-functions-youll-use\">Common Functions You&#8217;ll Use<\/a> \u00b7 <a href=\"#toc\">\ud83d\udcd1 Table of Contents<\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome! This guide helps you get started quickly with programming a FactoryBox using an ESP32 micro-controller \u2013 a beginner-friendly setup with LEDs, buttons, sensors, and displays connected to fixed GPIO pins. \u2747\ufe0f Just focus on coding. If you&#8217;re completely new to ESP32, Arduino, and PlatformIO, we recommend reading through this guide first to get comfortable [&hellip;]<\/p>\n","protected":false},"author":277789124,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_wpcom_ai_launchpad_about_page":false,"_wpcom_ai_launchpad_gallery_page":false,"_wpcom_ai_launchpad_contact_page":false,"_wpcom_ai_launchpad_events_page":false,"_wpcom_ai_launchpad_video_page":false,"_wpcom_ai_launchpad_portfolio_piece":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"footnotes":""},"class_list":["post-161","page","type-page","status-publish","hentry"],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/Ph6Zln-2B","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/learningfactorybox.com\/de\/wp-json\/wp\/v2\/pages\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learningfactorybox.com\/de\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learningfactorybox.com\/de\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learningfactorybox.com\/de\/wp-json\/wp\/v2\/users\/277789124"}],"replies":[{"embeddable":true,"href":"https:\/\/learningfactorybox.com\/de\/wp-json\/wp\/v2\/comments?post=161"}],"version-history":[{"count":100,"href":"https:\/\/learningfactorybox.com\/de\/wp-json\/wp\/v2\/pages\/161\/revisions"}],"predecessor-version":[{"id":1800,"href":"https:\/\/learningfactorybox.com\/de\/wp-json\/wp\/v2\/pages\/161\/revisions\/1800"}],"wp:attachment":[{"href":"https:\/\/learningfactorybox.com\/de\/wp-json\/wp\/v2\/media?parent=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}