{"id":52283,"date":"2026-11-01T10:50:51","date_gmt":"2026-11-01T10:50:51","guid":{"rendered":"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/"},"modified":"2026-11-01T10:50:51","modified_gmt":"2026-11-01T10:50:51","slug":"led-and-resistor","status":"publish","type":"siratek_tutorial","link":"https:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/","title":{"rendered":"Your First Circuit, an LED and a Resistor"},"content":{"rendered":"<body><p><\/p>\n<h2>What it does<\/h2>\n<p>An LED is a diode that gives off light when current passes through it the right way. Two things follow from that, and they are the whole of this tutorial: it only works one way round, and it needs something to limit the current.<\/p>\n<p>This is the first circuit you build yourself rather than one already wired onto a module. Every output project after this is a variation on it, and the traffic light module you may have already used is three of these on one board with the resistors fitted for you.<\/p>\n<h2>Before you begin<\/h2>\n<h3>Required parts and tools<\/h3>\n<ul>\n<li>An Arduino Uno or compatible board, already set up.<\/li>\n<li>One 5 mm LED. Red is the easiest to start with.<\/li>\n<li>One 220 ohm resistor.<\/li>\n<li>A breadboard and two jumper wires.<\/li>\n<\/ul>\n<h3>Which leg is which<\/h3>\n<p>An LED has no markings, so it is identified by shape.<\/p>\n<ul>\n<li>The <strong>longer leg<\/strong> is the anode, the positive side. Current enters here.<\/li>\n<li>The <strong>shorter leg<\/strong> is the cathode, the negative side, and goes to ground.<\/li>\n<li>The rim of the plastic body has a <strong>flat spot<\/strong> on the cathode side. This is the reliable test, because legs get trimmed.<\/li>\n<\/ul>\n<p>Connected backwards, an LED simply does nothing. It is not damaged and it is not a sign of a fault, so if your circuit is silent, turn the LED round before suspecting anything else.<\/p>\n<h3>Why the resistor is not optional<\/h3>\n<p>An LED has a roughly fixed forward voltage and almost no resistance beyond it. Connected straight to a 5 V pin, the only thing limiting the current is the wiring, which limits nothing. The LED will be very bright for an instant and then permanently dark, and the pin may be damaged with it.<\/p>\n<p><em>Voltage, Current and Resistance<\/em> works through the sum. For a red LED on a 5 V pin, 220 ohms gives about 13 mA, which is comfortable for both the LED and the pin.<\/p>\n<p>The resistor can go on either side of the LED. Current is the same all the way round a series circuit, so it does not matter whether it sits before or after.<\/p>\n<h3>Safety notes<\/h3>\n<p>Nothing here is dangerous to you. Wire it with the USB cable unplugged so that a mistake is found before it is powered.<\/p>\n<h2>Pin reference<\/h2>\n<table>\n<thead>\n<tr>\n<th>Pin or label<\/th>\n<th>Connect to<\/th>\n<th>Purpose<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>LED long leg, anode<\/td>\n<td>One end of the resistor<\/td>\n<td>Current in<\/td>\n<td>Flat spot on the body is the <em>other<\/em> side<\/td>\n<\/tr>\n<tr>\n<td>Resistor, other end<\/td>\n<td>Uno <code>D9<\/code><\/td>\n<td>The driving signal<\/td>\n<td>220 ohms for a red LED on 5 V<\/td>\n<\/tr>\n<tr>\n<td>LED short leg, cathode<\/td>\n<td>Uno <code>GND<\/code><\/td>\n<td>Return path<\/td>\n<td>The flat-spot side<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Pin <code>9<\/code> is used because it can also do PWM, which the last sketch needs. Any digital pin works for plain blinking.<\/p>\n<figure class=\"siratek-tutorial-figure\"><img decoding=\"async\" src=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-and-resistor-wiring.svg\" alt=\"An LED and a 220 ohm resistor wired between digital pin 9 and ground, with the flat side of the LED on the ground side\" loading=\"lazy\"><figcaption>The flat on the rim marks the short leg, and that side goes to ground.<\/figcaption><\/figure>\n<h2>Wiring steps<\/h2>\n<ol>\n<li>Unplug the USB cable.<\/li>\n<li>Push the LED into the breadboard so its two legs are in <strong>different rows<\/strong>. Both legs in one row is a short, and the most expensive mistake on a breadboard.<\/li>\n<li>Put one end of the resistor in the same row as the LED\u2019s long leg, and its other end in a free row.<\/li>\n<li>Run a wire from that free row to digital pin <code>9<\/code>.<\/li>\n<li>Run a wire from the LED\u2019s short leg row to a <code>GND<\/code> pin.<\/li>\n<li>Check the flat spot on the LED body is on the ground side.<\/li>\n<li>Plug the USB cable back in.<\/li>\n<\/ol>\n<h2>Software and libraries<\/h2>\n<p>No library is required. <code>pinMode()<\/code>, <code>digitalWrite()<\/code> and <code>analogWrite()<\/code> are part of the Arduino core.<\/p>\n<h2>Minimal working example<\/h2>\n<pre><code>\/\/ Siratek: blinking an LED on a breadboard.\n\nconst int ledPin = 9;\n\nvoid setup() {\n  pinMode(ledPin, OUTPUT);\n  Serial.begin(9600);\n  Serial.println(\"Siratek: LED circuit running.\");\n}\n\nvoid loop() {\n  digitalWrite(ledPin, HIGH);\n  delay(500);\n  digitalWrite(ledPin, LOW);\n  delay(500);\n}<\/code><\/pre>\n<h3>Fading it<\/h3>\n<p>Pin 9 can switch fast enough to make the LED look dim rather than off. <code>analogWrite()<\/code> takes a number from 0 to 255, where 0 is off and 255 is fully on.<\/p>\n<pre><code>\/\/ Siratek: fading the LED up and down.\n\nconst int ledPin = 9;\n\nvoid setup() {\n  pinMode(ledPin, OUTPUT);\n}\n\nvoid loop() {\n  for (int level = 0; level &lt;= 255; level++) {\n    analogWrite(ledPin, level);\n    delay(5);\n  }\n\n  for (int level = 255; level &gt;= 0; level--) {\n    analogWrite(ledPin, level);\n    delay(5);\n  }\n}<\/code><\/pre>\n<p>The LED is not really being dimmed. It is being switched on and off hundreds of times a second, too fast to see, and your eye averages it. <em>Dimming and Speed Control with PWM<\/em> explains what is happening and which pins can do it.<\/p>\n<h2>Expected result<\/h2>\n<p>The first sketch blinks the LED on and off twice a second. The second makes it brighten smoothly over about a second and a quarter, then fade back.<\/p>\n<p>The fade is not perfectly even to the eye. Brightness is perceived roughly logarithmically, so the low end of the range looks like a bigger change than the high end. That is your eye, not a fault.<\/p>\n<h2>Troubleshooting<\/h2>\n<table>\n<thead>\n<tr>\n<th>Symptom<\/th>\n<th>Likely cause<\/th>\n<th>Check or fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Nothing lights<\/td>\n<td>LED the wrong way round<\/td>\n<td>Turn it round; the flat spot goes to ground<\/td>\n<\/tr>\n<tr>\n<td>Nothing lights, LED confirmed<\/td>\n<td>Both legs in the same row<\/td>\n<td>Move one leg to its own row<\/td>\n<\/tr>\n<tr>\n<td>Nothing lights, wiring confirmed<\/td>\n<td><code>GND<\/code> wire missing<\/td>\n<td>Trace the path from pin to LED to ground<\/td>\n<\/tr>\n<tr>\n<td>Very bright flash, then dead<\/td>\n<td>No resistor fitted<\/td>\n<td>Replace the LED and fit 220 ohms<\/td>\n<\/tr>\n<tr>\n<td>Very dim<\/td>\n<td>Resistor far too large<\/td>\n<td>A 10 k resistor passes well under a milliamp<\/td>\n<\/tr>\n<tr>\n<td>Lights but will not blink<\/td>\n<td>Wrong pin in the sketch<\/td>\n<td>Match <code>ledPin<\/code> to the pin you wired<\/td>\n<\/tr>\n<tr>\n<td>Fading does not work, only on and off<\/td>\n<td>Not a PWM pin<\/td>\n<td>Use 3, 5, 6, 9, 10 or 11<\/td>\n<\/tr>\n<tr>\n<td>Flickers<\/td>\n<td>Loose leg in the breadboard<\/td>\n<td>Reseat with the power off<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Next steps<\/h2>\n<ul>\n<li><strong>Easier first:<\/strong> <em>Voltage, Current and Resistance<\/em>, if the resistor choice was the unclear part.<\/li>\n<li><strong>Related product:<\/strong> the RGB LED, which is three of these in one package.<\/li>\n<li><strong>Next project:<\/strong> <em>Dimming and Speed Control with PWM<\/em>, then drive the LED from a potentiometer.<\/li>\n<\/ul>\n<h2>Sources and attribution<\/h2>\n<p>All text, wiring guidance and code in this tutorial are original Siratek work.<\/p>\n<ul>\n<li>Arduino core documentation for <code>digitalWrite()<\/code> and <code>analogWrite()<\/code>.<\/li>\n<li>Arduino Uno R3 documentation for the per-pin current limit.<\/li>\n<\/ul>\n<p>LED forward voltages vary between parts, so the resistor value is given for a typical red 5 mm LED and should be recalculated for other colours. No third-party tutorial text, diagrams, photographs or code has been reproduced here.<\/p>\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>An LED is a diode that gives off light when current passes through it the right way. Two things follow from that, and they are the whole of this tutorial: it only works one way round, and it needs something&#8230;<\/p>\n","protected":false},"featured_media":0,"template":"","siratek_tutorial_level":[],"class_list":["post-52283","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>Your First Circuit, an LED and a Resistor - 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\/led-and-resistor\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Your First Circuit, an LED and a Resistor - siratek\" \/>\n<meta property=\"og:description\" content=\"An LED is a diode that gives off light when current passes through it the right way. Two things follow from that, and they are the whole of this tutorial: it only works one way round, and it needs something...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/\" \/>\n<meta property=\"og:site_name\" content=\"siratek\" \/>\n<meta property=\"og:image\" content=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-and-resistor-wiring.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\\\/led-and-resistor\\\/\",\"url\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-and-resistor\\\/\",\"name\":\"Your First Circuit, an LED and a Resistor - siratek\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-and-resistor\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-and-resistor\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/led-and-resistor-wiring.svg\",\"datePublished\":\"2026-11-01T10:50:51+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-and-resistor\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-and-resistor\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-and-resistor\\\/#primaryimage\",\"url\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/led-and-resistor-wiring.svg\",\"contentUrl\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/led-and-resistor-wiring.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-and-resistor\\\/#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\":\"Your First Circuit, an LED and a Resistor\"}]},{\"@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":"Your First Circuit, an LED and a Resistor - 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\/led-and-resistor\/","og_locale":"en_US","og_type":"article","og_title":"Your First Circuit, an LED and a Resistor - siratek","og_description":"An LED is a diode that gives off light when current passes through it the right way. Two things follow from that, and they are the whole of this tutorial: it only works one way round, and it needs something...","og_url":"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/","og_site_name":"siratek","og_image":[{"url":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-and-resistor-wiring.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\/led-and-resistor\/","url":"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/","name":"Your First Circuit, an LED and a Resistor - siratek","isPartOf":{"@id":"https:\/\/siratek.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/#primaryimage"},"image":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/#primaryimage"},"thumbnailUrl":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-and-resistor-wiring.svg","datePublished":"2026-11-01T10:50:51+00:00","breadcrumb":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/#primaryimage","url":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-and-resistor-wiring.svg","contentUrl":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-and-resistor-wiring.svg"},{"@type":"BreadcrumbList","@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-and-resistor\/#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":"Your First Circuit, an LED and a Resistor"}]},{"@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\/52283","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\/52283\/revisions"}],"wp:attachment":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/media?parent=52283"}],"wp:term":[{"taxonomy":"siratek_tutorial_level","embeddable":true,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial_level?post=52283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}