Arduino Neopixel

by LoganPaxton in Circuits > Arduino

88 Views, 0 Favorites, 0 Comments

Arduino Neopixel

Screenshot 2024-10-04 11.07.46 PM.png

Welcome back to another instructable! Today, we are going to be making our very own Neopixel.

Supplies

The supplies needed for this project are:

  1. Arduino Uno R3: https://a.co/d/0lki3hk (x1)
  2. Jumper Wires: https://s.click.aliexpress.com/e/_DEv98Cd (x3)
  3. Neopixel: https://www.adafruit.com/product/1612 (x1)

Note: You may have to solder in this tutorial, these steps will not be provided. Also, you can use different Neopixels, but you may have to modify the code slightly.

Wiring

Screenshot 2024-10-04 10.58.24 PM.png

Let's start wiring. To begin, we need to first, wire the IN pin to any digital output pin on your Arduino, for this example, I've used pin 2. Now, you need to wire the G to ground, and + to the 5V pin. Once you have completed that, you may now move onto coding your Neopixel!

Coding

Screenshot 2024-10-04 11.07.46 PM.png

Now, in this step we will be coding our Neopixel. So, let's begin! First, we want to include our Adafruit library, and go ahead and make some crucial variables.

Note: I have provided the .ino file below for you

#include <Adafruit_NeoPixel.h>

#define LED_PIN 2
#define LED_COUNT 1

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// NEO_GRB means how it will send the color signals, green, red, and finally blue. You may need to change it.


Now, let's go ahead and get our setup and loop functions.

void setup() {
strip.begin();
strip.show(); // Clears out the colors from the previous program
}

void loop() {
strip.setPixelColor(0, 255, 0, 0); // Takes normal R, G, B color codes.
// First argument is what pixel you want to set the color of, for this example, it would be the first pixel (And the only one)
strip.show(); // Make sure you add this line, or your color won't show. (This has got me a few times :C)
}


Put together, the code should look something like this

#include <Adafruit_NeoPixel.h>

#define LED_PIN 2
#define LED_COUNT 1

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// NEO_GRB means how it will send the color signals, green, red, and finally blue.

void setup() {
strip.begin();
strip.show(); // Clears out the colors from the previous program
}

void loop() {
strip.setPixelColor(0, 255, 0, 0); // Takes normal R, G, B color codes.
// First argument is what pixel you want to set the color of, for this example, it would be the first pixel (And the only one)
strip.show(); // Make sure you add this line, or your color won't show. (This has got me a few times :C)
}


There you have it! Your own custom Neopixel! If you liked this tutorial, please, make sure you favorite it!


TROUBLESHOOTING:

  1. Try changing line 6, NEO_GRB to NEO_RGB, or NEO_BRG
  2. Copy and paste the code above
  3. Confirm you've wired the pins correctly
  4. Confirm that you've used strip.show(); on line 17

Downloads