<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Simplify - Articles tagged with Arduino Nano</title>
  <subtitle>Personal website of Saša Jovanić</subtitle>
  <id>https://www.simplify.ba/articles/tags/arduino-nano/</id>
  <link href="https://www.simplify.ba/articles/tags/arduino-nano/"/>
  <link href="https://www.simplify.ba/articles/tags/arduino-nano/feed.xml" rel="self"/>
  <updated>2021-12-17T19:12:00+01:00</updated>
  <author>
    <name>Saša Jovanić</name>
  </author>
  <entry>
    <title>Arduino controlling LED strip</title>
    <link rel="alternate" href="https://www.simplify.ba/articles/2017/01/08/arduino-controlling-led-strip/"/>
    <id>https://www.simplify.ba/articles/2017/01/08/arduino-controlling-led-strip/</id>
    <published>2017-01-08T18:33:00+01:00</published>
    <updated>2017-01-11T20:29:46+01:00</updated>
    <author>
      <name>Saša Jovanić</name>
    </author>
    <content type="html">&lt;p&gt;In the last week of previous year I decided to build lighting behind my bed. I don't like lamps, so basic idea was to use &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; strip. Initially, I wanted to use &lt;a href="http://nodemcu.com/index_en.html" target="_blank"&gt;NodeMCU&lt;/a&gt; and control light using phone or tablet with HomeKit. However, that still requires me to build server that emulates HomeKit API like a &lt;a href="https://github.com/nfarina/homebridge" target="_blank"&gt;homebridge&lt;/a&gt; or &lt;a href="https://github.com/KhaosT/HAP-NodeJS" target="_blank"&gt;HAP-NodeJS&lt;/a&gt; and &lt;a href="http://www.orangepi.org/orangepizero/" target="_blank"&gt;Orange Pi Zero&lt;/a&gt; is better hardware choice for this. You get full operating system on that board and can run node server and control &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; strip on same hardware. Not having any Orange Pi board around and with wish to make something to test colors and effects, even temporary, I end up using &lt;a href="https://www.arduino.cc/en/Main/arduinoBoardNano" target="_blank"&gt;Arduino Nano&lt;/a&gt;. I'm planning to revisit this project (hopefully) during this year, but with Orange Pi Zero. It also depends on results of this project and amount of lighting provided.&lt;/p&gt;

&lt;h2 id="project-requirements"&gt;Project requirements&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Different "modes" for lighting, solid light colors, different effects&lt;/li&gt;
  &lt;li&gt;On/off hardware switch&lt;/li&gt;
  &lt;li&gt;Button for toggling between modes&lt;/li&gt;
  &lt;li&gt;indicator &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; that lights only during start-up or when i toggle between modes&lt;/li&gt;
  &lt;li&gt;Easy way to modify Arduino software&lt;/li&gt;
  &lt;li&gt;Easy way to modify hardware and/or disassemble whole thing&lt;/li&gt;
  &lt;li&gt;Must support 100 LEDs&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id="schematics-and-build"&gt;Schematics and build&lt;/h2&gt;

&lt;p&gt;&lt;a href="/articles/2017/01/08/arduino-controlling-led-strip/schema.png"&gt;&lt;img src="/articles/2017/01/08/arduino-controlling-led-strip/schema.png" alt="Schema" class="media-30p" /&gt;&lt;/a&gt;
&lt;a href="/articles/2017/01/08/arduino-controlling-led-strip/bb.png"&gt;&lt;img src="/articles/2017/01/08/arduino-controlling-led-strip/bb.png" alt="Breadboard" class="media-30p" /&gt;&lt;/a&gt;
&lt;a href="/articles/2017/01/08/arduino-controlling-led-strip/in_box.jpg"&gt;&lt;img src="/articles/2017/01/08/arduino-controlling-led-strip/in_box.jpg" alt="Build" class="media-30p" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please note that I'm not using any resistor before indicator &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt;. The reason is that blue &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; diodes require 3.4V and those are more resistant to 5V. In my case that &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; will burn only for a short amount of time and I don't expect it to burn out. However, this is not good practice and adding 220Ω resistor is much better choice.&lt;/p&gt;

&lt;p&gt;For building I used anything that was around, industrial electric box with IP45 rating, small 5x7cm perfboard, through hole components,… Jumper wires will help if I need to disassemble whole thing. Also, I left short USB cable attached to the board. This way i can easily change Arduino software.&lt;/p&gt;

&lt;p&gt;Every &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; in strip uses 0.060 mA when fully bright. That means that for 100 LEDs in strip we need at least 6A power supply to support full brightness. At least, because Arduino board will also use some power. Best thing that I had was 5V/5A power supply and that was good enough for this project. Even this limit when I set all 100 LEDs to white, it's still too bright for my taste.&lt;/p&gt;

&lt;h2 id="software"&gt;Software&lt;/h2&gt;

&lt;p&gt;To build this I used standard Arduino IDE, version 1.8.0. I don't like it at all, but didn't want to spend any time to configure Emacs for Arduino for this simple (and probably temporary) project.&lt;/p&gt;

&lt;p&gt;You can see &lt;a href="https://github.com/Simplify/arduino-led-strip"&gt;source code here&lt;/a&gt;. Please keep in mind that I may change a lot in this code and this article may not be following same code version any more when you read this. In that case see &lt;a href="https://github.com/Simplify/arduino-led-strip/tree/70d8bfd8159c156fe87e31360859b5d3b408a396"&gt;1.0.0 tag&lt;/a&gt; in git.&lt;/p&gt;

&lt;p&gt;Only library used in this project is &lt;a href="http://fastled.io/"&gt;FastLED&lt;/a&gt; and it can be installed using "Library Manager" inside Arduino IDE. Great thing is that you can specify colors using &lt;abbr title="Red, Green, Blue"&gt;RGB&lt;/abbr&gt; or &lt;abbr title="Hue, Saturation, Value (Brightness)"&gt;HSV&lt;/abbr&gt; and it's fast.&lt;/p&gt;

&lt;p&gt;There are 7 solid color modes: black , white, red, green, blue, yellow and purple. Black is basically "off", makes all LEDs &lt;code&gt;0x000000&lt;/code&gt;. I'll probably remove green and yellow and make white color less bright.&lt;/p&gt;

&lt;p&gt;Current effects are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;one_at_a_time&lt;/code&gt; - Loops from first to the last &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; with only one &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; on at the same time, red, green or blue. I'll or remove this effect or change it.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;bars&lt;/code&gt; - Sets all LEDs off and than loops from first to the last &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; in strip setting that diode on in red, green or blue. I'll or remove or change this effect in the future.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;fade&lt;/code&gt; - Sets slowly all LEDs in strip from off to red, green or blue ate the same time and than slowly sets all LEDs off. Fade in -fade out effect, looks a lot like a "breed" &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; on MacBook Pro. It's nice, but probably stick with only one color in the future.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;fire&lt;/code&gt; - Creates flickering fire effect. Looks great, but because of strip position and distance between bed and wall looks too yellow. Need to change this one.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;twinkle&lt;/code&gt; - Lights slowly up to 40 random LEDs with red color. After that starts switching off those LEDs and every time one &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; is switched off, another one random &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; becomes lit. Sometimes looks more like a fire than &lt;code&gt;fire&lt;/code&gt; effect.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;twinkle_random&lt;/code&gt; - Same as &lt;code&gt;twinkle&lt;/code&gt;, but colors are also random. Works better with higher saturation.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;twinkle_single&lt;/code&gt; - Same as &lt;code&gt;twinkle&lt;/code&gt;, but only one &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; is lit red.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;sparkle&lt;/code&gt; - Sets all LEDs off and than sets random single to &lt;code&gt;0xFFFFFF&lt;/code&gt;, sets it off and select next random &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; for same effect. Very similar to &lt;code&gt;twinkle_single&lt;/code&gt;, but faster. Maybe even too fast and that make this one annoying. I may remove it or merge it with &lt;code&gt;twinkle_single&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;snow_sparkle&lt;/code&gt; - Same as above, but all other LEDs are not off but set to &lt;code&gt;0x101010&lt;/code&gt;. I like this one more.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;strobe&lt;/code&gt; - Strobe effect. Annoying and disabled.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please keep in mind that color choices and effects used in this version are not final. I used red, green and blue just as a test in many cases to get code and desired effect working. I'm going to change a lot in the future, based on testing in real situations. Also, speed, brightness and colors depend on some external factors, like other lights in the room or distance between back of my bed (where &lt;abbr title="Light Emitting Diode"&gt;LED&lt;/abbr&gt; strip is located) and the wall. Some effects may look different when you try them.&lt;/p&gt;

</content>
  </entry>
</feed>
