{"id":52255,"date":"2026-11-01T10:50:46","date_gmt":"2026-11-01T10:50:46","guid":{"rendered":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/"},"modified":"2026-11-01T10:50:46","modified_gmt":"2026-11-01T10:50:46","slug":"how-arduino-works","status":"publish","type":"siratek_tutorial","link":"https:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/","title":{"rendered":"How an Arduino Actually Works"},"content":{"rendered":"<body><p><\/p>\n<h2>What this covers<\/h2>\n<p>You have uploaded a sketch and watched an LED blink. This explains what was actually happening, because almost every confusing moment later comes from a wrong mental picture of it.<\/p>\n<p>There is no reading to do at a bench for this one. It takes about twenty minutes and will save you several hours.<\/p>\n<h2>Before you begin<\/h2>\n<p>Have a board plugged in and the Arduino IDE open, so you can try the small experiments as you go. Everything here applies to an Arduino Uno and the ATmega328P chip at its centre.<\/p>\n<h2>It is not a small computer<\/h2>\n<p>A laptop runs an operating system, which starts and stops programs, shares the processor between them, and keeps running when a program ends.<\/p>\n<p>An Arduino has none of that. One program is stored on the chip, and it starts the instant the board receives power. There is nothing underneath it, nothing beside it, and nothing to return to when it finishes. That is why your program never ends. If it did, the chip would have nothing to do.<\/p>\n<p>This is a feature, not a limitation. The board does exactly one job, starts in under a second, and behaves identically every time it is switched on.<\/p>\n<h2>Where your program lives<\/h2>\n<p>The ATmega328P has three kinds of memory, and knowing which is which explains a whole class of bugs.<\/p>\n<table>\n<thead>\n<tr>\n<th>Memory<\/th>\n<th>Size on an Uno<\/th>\n<th>Holds<\/th>\n<th>On power loss<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Flash<\/td>\n<td>32 KB, around 0.5 KB used by the bootloader<\/td>\n<td>Your compiled program<\/td>\n<td>Kept<\/td>\n<\/tr>\n<tr>\n<td>SRAM<\/td>\n<td>2 KB<\/td>\n<td>Variables while the program runs<\/td>\n<td>Lost<\/td>\n<\/tr>\n<tr>\n<td>EEPROM<\/td>\n<td>1 KB<\/td>\n<td>Small values you deliberately save<\/td>\n<td>Kept<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Your sketch goes into flash. Every variable it uses lives in SRAM, which is why a counter starts again at zero when you unplug the board, and why storing long text can quietly exhaust a board long before the program itself is too big.<\/p>\n<figure class=\"siratek-tutorial-figure\"><img decoding=\"async\" src=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/how-arduino-works-memory-and-loop.svg\" alt=\"The chip's three kinds of memory and what survives a reset, then the setup and loop cycle\" loading=\"lazy\"><figcaption>SRAM is the one that runs out, and the only one wiped on every reset.<\/figcaption><\/figure>\n<h2><code>setup()<\/code> and <code>loop()<\/code><\/h2>\n<p>Every sketch has these two functions, and the reason is simple. Hidden inside the Arduino core is roughly this:<\/p>\n<pre><code>int main() {\n  init();    \/\/ Sets up timers and the hardware the core depends on.\n  setup();   \/\/ Your code, run once.\n\n  for (;;) {\n    loop();  \/\/ Your code, run again and again, forever.\n  }\n}<\/code><\/pre>\n<p>That is the whole model. <code>setup()<\/code> runs once, for the things that only need doing once: setting pin directions, opening the serial link, starting a library. Then <code>loop()<\/code> is called over and over, as fast as the chip can manage, until the power goes.<\/p>\n<p>A 16 MHz Uno runs sixteen million basic operations per second. An empty <code>loop()<\/code> runs tens of thousands of times a second, which is why anything you want to happen at a human pace needs timing of some kind.<\/p>\n<h2>One thing at a time<\/h2>\n<p>The chip executes one instruction, then the next. Nothing happens in parallel.<\/p>\n<p>This is the single most useful fact in the whole library, because it explains <code>delay()<\/code>. When you write <code>delay(1000)<\/code>, the chip is not waiting in the background. It is stuck, counting, doing nothing else at all. A button pressed during that second is not noticed, not queued, and not remembered.<\/p>\n<pre><code>void loop() {\n  digitalWrite(ledPin, HIGH);\n  delay(1000);                 \/\/ Nothing else can happen for a full second.\n  digitalWrite(ledPin, LOW);\n  delay(1000);                 \/\/ Nor here.\n}<\/code><\/pre>\n<p>For a blinking light that is fine. For anything that has to react, it is not, and the fix is a tutorial of its own later in this library.<\/p>\n<h2>What uploading does<\/h2>\n<p>When you click Upload, four things happen in order.<\/p>\n<ol>\n<li>The IDE compiles your sketch into machine code for the ATmega328P, and reports any mistakes instead of continuing.<\/li>\n<li>It resets the board over the USB connection.<\/li>\n<li>A small program called the <strong>bootloader<\/strong>, already in flash, runs first on reset. For a moment it listens on the serial line to see whether a new sketch is arriving.<\/li>\n<li>If one is, the bootloader writes it into flash and then starts it. If not, it steps aside and the sketch already there runs.<\/li>\n<\/ol>\n<p>That brief listening window is why uploads sometimes fail when the serial port is busy, and why a board with a damaged bootloader has to be reprogrammed with separate hardware.<\/p>\n<h2>What reset does, and does not do<\/h2>\n<p>Pressing the reset button starts your program again from the first line of <code>setup()<\/code>. Variables in SRAM go back to their initial values.<\/p>\n<p>It does not erase your sketch. Flash keeps its contents with the power off and through any number of resets. The only way to change the program is to upload another one.<\/p>\n<h2>What a pin really is<\/h2>\n<p>A digital pin is a physical connection to the chip that can be switched between two jobs.<\/p>\n<ul>\n<li>As an <strong>output<\/strong>, the chip connects the pin either to 5 V or to ground, so it can push a small current into something.<\/li>\n<li>As an <strong>input<\/strong>, the pin is left high-impedance and the chip simply measures whether the voltage on it is nearer 5 V or nearer 0 V.<\/li>\n<\/ul>\n<p><code>pinMode()<\/code> is what chooses between those, and it is why an output pin driving nothing is harmless while an input pin connected to nothing reads unpredictable nonsense. There is no voltage on it to measure.<\/p>\n<h2>Check yourself<\/h2>\n<p>Answer these before moving on. If one of them is not obvious, read that section again.<\/p>\n<ol>\n<li>You unplug the board mid-count and plug it back in. What does the counter show?<\/li>\n<li>Your sketch calls <code>delay(5000)<\/code> and you press a button after two seconds. Does the program see the press?<\/li>\n<li>You press reset. Is the sketch still on the board?<\/li>\n<li>Why does <code>setup()<\/code> not need to be called from anywhere in your code?<\/li>\n<\/ol>\n<h2>Next steps<\/h2>\n<ul>\n<li><strong>Easier first:<\/strong> <em>Getting Started with Arduino Uno<\/em>, if you have not uploaded anything yet.<\/li>\n<li><strong>Next:<\/strong> <em>Voltage, Current and Resistance<\/em>, which covers the electrical side of the same picture.<\/li>\n<li><strong>Later:<\/strong> timing without <code>delay()<\/code>, once you have built something that needs to react while it waits.<\/li>\n<\/ul>\n<h2>Sources and attribution<\/h2>\n<p>All text and code in this tutorial are original Siratek work.<\/p>\n<ul>\n<li>ATmega328P datasheet, for memory sizes and clock speed.<\/li>\n<li>Arduino core source and documentation, for the <code>main()<\/code> structure and the bootloader\u2019s role.<\/li>\n<\/ul>\n<p>No third-party tutorial text, diagrams, photographs or code has been reproduced here.<\/p>\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>You have uploaded a sketch and watched an LED blink. This explains what was actually happening, because almost every confusing moment later comes from a wrong mental picture of it.<\/p>\n","protected":false},"featured_media":0,"template":"","siratek_tutorial_level":[],"class_list":["post-52255","siratek_tutorial","type-siratek_tutorial","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How an Arduino Actually Works - siratek<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How an Arduino Actually Works - siratek\" \/>\n<meta property=\"og:description\" content=\"You have uploaded a sketch and watched an LED blink. This explains what was actually happening, because almost every confusing moment later comes from a wrong mental picture of it.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/\" \/>\n<meta property=\"og:site_name\" content=\"siratek\" \/>\n<meta property=\"og:image\" content=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/how-arduino-works-memory-and-loop.svg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/how-arduino-works\\\/\",\"url\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/how-arduino-works\\\/\",\"name\":\"How an Arduino Actually Works - siratek\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/how-arduino-works\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/how-arduino-works\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/how-arduino-works-memory-and-loop.svg\",\"datePublished\":\"2026-11-01T10:50:46+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/how-arduino-works\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/how-arduino-works\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/how-arduino-works\\\/#primaryimage\",\"url\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/how-arduino-works-memory-and-loop.svg\",\"contentUrl\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/how-arduino-works-memory-and-loop.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/how-arduino-works\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/siratek.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials\",\"item\":\"https:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How an Arduino Actually Works\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\",\"url\":\"https:\\\/\\\/siratek.net\\\/\",\"name\":\"siratek\",\"description\":\"Your Best Electronic Retail Shop\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/siratek.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How an Arduino Actually Works - siratek","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/","og_locale":"en_US","og_type":"article","og_title":"How an Arduino Actually Works - siratek","og_description":"You have uploaded a sketch and watched an LED blink. This explains what was actually happening, because almost every confusing moment later comes from a wrong mental picture of it.","og_url":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/","og_site_name":"siratek","og_image":[{"url":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/how-arduino-works-memory-and-loop.svg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/","url":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/","name":"How an Arduino Actually Works - siratek","isPartOf":{"@id":"https:\/\/siratek.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/#primaryimage"},"image":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/#primaryimage"},"thumbnailUrl":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/how-arduino-works-memory-and-loop.svg","datePublished":"2026-11-01T10:50:46+00:00","breadcrumb":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/#primaryimage","url":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/how-arduino-works-memory-and-loop.svg","contentUrl":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/how-arduino-works-memory-and-loop.svg"},{"@type":"BreadcrumbList","@id":"http:\/\/siratek.net\/index.php\/tutorials\/how-arduino-works\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/siratek.net\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"https:\/\/siratek.net\/index.php\/tutorials\/"},{"@type":"ListItem","position":3,"name":"How an Arduino Actually Works"}]},{"@type":"WebSite","@id":"https:\/\/siratek.net\/#website","url":"https:\/\/siratek.net\/","name":"siratek","description":"Your Best Electronic Retail Shop","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/siratek.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial"}],"about":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/types\/siratek_tutorial"}],"version-history":[{"count":0,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52255\/revisions"}],"wp:attachment":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/media?parent=52255"}],"wp:term":[{"taxonomy":"siratek_tutorial_level","embeddable":true,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial_level?post=52255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}