{"id":2580,"date":"2018-01-03T17:52:20","date_gmt":"2018-01-03T17:52:20","guid":{"rendered":"http:\/\/www.robertprice.co.uk\/robblog\/?p=2580"},"modified":"2018-01-03T17:52:20","modified_gmt":"2018-01-03T17:52:20","slug":"using-a-bicolour-led-with-a-nodemcu","status":"publish","type":"post","link":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/","title":{"rendered":"Using a bicolour LED with a NodeMCU"},"content":{"rendered":"<p>This is a quick example on how to use a bicolour LED with a NodeMCU.<\/p>\n<p>The bicolour LED has both red and green LEDs in a single package. There is a common cathode for both the red and green anodes. Applying a current to the red anode turns the red LED on. A current to green anode turns the green LED on. A current to both anodes creates yellow.<\/p>\n<p>The circuit is very simple. We wire the red anode to D1 on the NodeMCU, the green anode to D2, protecting them both with a 220ohm resistor. The cathode is wired to ground.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/red-green.png\" alt=\"Linking a bicolour LED to a NodeMCU\" width=\"594\" height=\"849\" class=\"aligncenter size-full wp-image-2582\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/red-green.png 594w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/red-green-210x300.png 210w\" sizes=\"auto, (max-width: 594px) 85vw, 594px\" \/><\/p>\n<p>We program the NodeMCU using an Arduino sketch.<\/p>\n<pre>int redPin = D1, greenPin = D2;\r\n\r\nvoid setup() {\r\n  \/\/ set the pins to output mode\r\n  pinMode(redPin, OUTPUT); \r\n  pinMode(greenPin, OUTPUT);\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ red\r\n  digitalWrite(redPin, HIGH); delay(500);\r\n  \/\/ yellow\r\n  digitalWrite(greenPin, HIGH); delay(500);\r\n  \/\/ green\r\n  digitalWrite(redPin, LOW); delay(500);\r\n  \/\/ off\r\n  digitalWrite(greenPin, LOW); delay(500);\r\n}\r\n<\/pre>\n<p>In the setup, we set D1 and D2 to both be outputs. We then turn D1 and D2 on and off in sequence every half a second to achieve a sequence of red, yellow, green, and off.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/ezgif-5-84dbf4c8ff.gif\" alt=\"\" width=\"480\" height=\"360\" class=\"aligncenter size-full wp-image-2584\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a quick example on how to use a bicolour LED with a NodeMCU. The bicolour LED has both red and green LEDs in a single package. There is a common cathode for both the red and green anodes. Applying a current to the red anode turns the red LED on. A current to &hellip; <a href=\"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using a bicolour LED with a NodeMCU&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2583,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[84],"tags":[96,86,91],"class_list":["post-2580","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hardware","tag-arduino","tag-led","tag-nodemcu"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using a bicolour LED with a NodeMCU - Robert Price<\/title>\n<meta name=\"description\" content=\"How to run a bicolour LED from a NodeMCU. A wiring diagram and working arduino sketch code is included in the article.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using a bicolour LED with a NodeMCU - Robert Price\" \/>\n<meta property=\"og:description\" content=\"How to run a bicolour LED from a NodeMCU. A wiring diagram and working arduino sketch code is included in the article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/\" \/>\n<meta property=\"og:site_name\" content=\"Robert Price\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-03T17:52:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/NodeMCU_BiColour_LED.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"rob\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rob\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/\"},\"author\":{\"name\":\"rob\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"headline\":\"Using a bicolour LED with a NodeMCU\",\"datePublished\":\"2018-01-03T17:52:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/\"},\"wordCount\":154,\"image\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/NodeMCU_BiColour_LED.jpg\",\"keywords\":[\"Arduino\",\"LED\",\"NodeMCU\"],\"articleSection\":[\"Hardware\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/\",\"name\":\"Using a bicolour LED with a NodeMCU - Robert Price\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/NodeMCU_BiColour_LED.jpg\",\"datePublished\":\"2018-01-03T17:52:20+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"description\":\"How to run a bicolour LED from a NodeMCU. A wiring diagram and working arduino sketch code is included in the article.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/NodeMCU_BiColour_LED.jpg\",\"contentUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/NodeMCU_BiColour_LED.jpg\",\"width\":1200,\"height\":600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/using-a-bicolour-led-with-a-nodemcu\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using a bicolour LED with a NodeMCU\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\",\"name\":\"Robert Price\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\",\"name\":\"rob\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"caption\":\"rob\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using a bicolour LED with a NodeMCU - Robert Price","description":"How to run a bicolour LED from a NodeMCU. A wiring diagram and working arduino sketch code is included in the article.","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":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/","og_locale":"en_GB","og_type":"article","og_title":"Using a bicolour LED with a NodeMCU - Robert Price","og_description":"How to run a bicolour LED from a NodeMCU. A wiring diagram and working arduino sketch code is included in the article.","og_url":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/","og_site_name":"Robert Price","article_published_time":"2018-01-03T17:52:20+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/NodeMCU_BiColour_LED.jpg","type":"image\/jpeg"}],"author":"rob","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rob","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/#article","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/"},"author":{"name":"rob","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"headline":"Using a bicolour LED with a NodeMCU","datePublished":"2018-01-03T17:52:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/"},"wordCount":154,"image":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/#primaryimage"},"thumbnailUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/NodeMCU_BiColour_LED.jpg","keywords":["Arduino","LED","NodeMCU"],"articleSection":["Hardware"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/","url":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/","name":"Using a bicolour LED with a NodeMCU - Robert Price","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/#primaryimage"},"image":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/#primaryimage"},"thumbnailUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/NodeMCU_BiColour_LED.jpg","datePublished":"2018-01-03T17:52:20+00:00","author":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"description":"How to run a bicolour LED from a NodeMCU. A wiring diagram and working arduino sketch code is included in the article.","breadcrumb":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/#primaryimage","url":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/NodeMCU_BiColour_LED.jpg","contentUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/NodeMCU_BiColour_LED.jpg","width":1200,"height":600},{"@type":"BreadcrumbList","@id":"https:\/\/www.robertprice.co.uk\/robblog\/using-a-bicolour-led-with-a-nodemcu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.robertprice.co.uk\/robblog\/"},{"@type":"ListItem","position":2,"name":"Using a bicolour LED with a NodeMCU"}]},{"@type":"WebSite","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website","url":"https:\/\/www.robertprice.co.uk\/robblog\/","name":"Robert Price","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5","name":"rob","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","caption":"rob"}}]}},"_links":{"self":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/2580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/comments?post=2580"}],"version-history":[{"count":2,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/2580\/revisions"}],"predecessor-version":[{"id":2585,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/2580\/revisions\/2585"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media\/2583"}],"wp:attachment":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media?parent=2580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/categories?post=2580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/tags?post=2580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}