I'm attempting to light up a WS2812B LED strip using an Arduino. I have my Arduino Leonardo (Also have tried a Nano) connected through USB to my computer. I can run a standard program that outputs 5V on Pin #9. Everything works fine using the code below. I do not have anything connected to the Arduino besides the power supply.
void setup() {
pinMode(9, OUTPUT);
}
void loop() {
digitalWrite(9, HIGH);
delay(10000);
digitalWrite(9, LOW);
delay(10000);
}
The voltage toggles from +5V to 0V every 10 seconds, just as the code says. I'm running into issues when I try to do any simple code using the FastLed or NeoPixel library. At this time, I'm not connecting the LED strip to the Arduino. I'm attempting this one step at a time before connecting the Power supply and LED strip.
When uploading the code below, I'm not reading any voltage on Pin #9 of my Arduino. Remember, I have nothing connected to the Arduino besides my USB from the computer for power.
#include <FastLED.h>
#define NUM_LEDS 1
#define LED_PIN 9
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812B, LED_PIN>(leds, NUM_LEDS);
}
void loop() {
leds[0] = CRGB::Red;
FastLED.show();
delay(10000);
}
After trying the FastLED library for quite a long time, I read that changing the library could fix the issue. I tried a simple program using the NeoPixel library, which is posted below.
#include <Adafruit_NeoPixel.h>
#define PIN 9
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 5000 // Time (in milliseconds) to pause between pixels
void setup() {
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
void loop() {
pixels.clear(); // Set all pixel colors to 'off'
pixels.setPixelColor(0, pixels.Color(0, 150, 0));
pixels.show(); // Send the updated pixel colors to the hardware.
delay(DELAYVAL); // Pause before next pass through loop
}
After running this code I still am not reading any voltage on Pin #9. Is there something I'm missing? Should the pin be outputting 5V or will it be a lower value? Does the LED data pin have to be connected to Pin #9 for there to be voltage? I've tried editing my code in different ways but it usually ends up with me doing more harm than good.
It's worth mentioning that my code compiles fine without errors. I'm quite new to Arduino projects so there could be something very obvious that I'm missing. I've attached a picture of my Arduino but I don't believe it will be much help since I only have power in.
