NeoPixel is Adafruit’s brand for individually-addressable RGB color pixels and strips based on the WS2812, WS2811 and SK6812 LED/drivers, using a single-wire control protocol. Today, I am going to make a badge that displays a pixel art using NeoPixel. Why? The reason is simple. I couldn’t find the RGB badge that I wanted to have.
5 Minutes for crafting!
The materials you need are 3V to 5V DC converter, Arduino Nano board, battery charging module, copper wires, NeoPixel panel, Li-ion battery, On/Off switch and safety pins. You also need a glue gun, soldering iron and soldering skills for soldering and crafting.
If the pins of Arduino board that you own are soldered to other headers or ports, I recommend you to desolder them first.
Make sketchy locations for parts. I am going to arrange the parts like the image above. I decided to replace mini USB ports on Arduino and battery charging module with one USB-C port. Process of adding USB-C port is optional.
Connecting Arduino board to USB-C port. I am connecting not only power pins but also data pins. Please be aware of the polarity of pins.
Connect the battery to battery charging module. After that, connect power input pins on the module to USB-C port which was mentioned before.
Connect power output pins to the step-up converter(DC converter). NeoPixel and Arduino require 5V electricity supply while the battery output voltage is only 3.3V, thus the step-up procedure is required. ON/OFF switch will be located between the step-up converter and battery charging module.
Time to finalize the circuit! Connect VCC pin of Arduino board to +5V pin of NeoPixel board and +pin of the power output pin on step-up converter. Connect GND pin of Arduino to GND pin of NeoPixel and – pin of the power output pin on the boost converter. Connect DIN pin on NeoPixel to D6 pin on Arduino board. Now circuit is ready. Put the parts together using glue gun. Do not forget to stick a safety pin with them without contacting pin to circuit.
Now it’s time for software development.
Hello, world! Software ready to go!
Before making an Arduino C code for NeoPixel, you need to install library for NeoPixel module first. Please check here for details.
After library installation, you can build your own code or simply use my code instead. Please check here for downloading my code.
The content below is a brief description of my NeoPixel code.
In the project folder, there are 1 folder and a .ino file. Please open .ino file with Arduino IDE for editing code.
numLED is a constant value for the number of LED on NeoPixel module. If your NeoPixel module has more or less than 64 LED, please change this value.
pixelChangeTime is a value for the time in milliseconds spent for changing 1 pixel while using DotToDot animation (will be described later).
FadeInSpeed is a time in milliseconds for fade in/out animation.
LEDBrightness is a value setting the brightness of the LEDs.
paint[numLED] is the RGB array for saving image which will be displayed on NeoPixel module.
setup() is the initial function that the Arduino board will execute after first boot. This function will be executed only once. I set this device to display a blank screen for 1 second.
loop() is the iterative function which will be executed after the execution of setup() function. The initial content of loop() function is fading in and out an image. To change the animation, you can use the presets I made or build your own function. The functions for making image to be displayed are picIncodeFadeIn(), picIncodeDotToDot() and picIncodeInstant(), and the functions for making the image to be disappeared are imgDisappearFadeOut(), imgDisappearDotToDot() and screenBlank().
Functions for illustration
- picIncodeFadeIn() function let the image to fade in.
- picIncodeDotToDot() function let image to appear pixel-by-pixel.
- picIncodeInstant() function make image to appear instantly.
Functions for making images to be disappeared
- imgDisappearFadeOut() function let image to fade out.
- imgDisappearDotToDot() function let image to disappear pixel-by-pixel.
- screenBlank() turns off every LEDs on the NeoPixel module.
Parts were bit expensive, but the quality of the outcome was acceptable.
Please donate me some money. I want to make whatever I want without worrying about budget…