Hi all,
A little background first. This is my first attempt at using programming to interface with hardware, it is my first experience using a micro-controller and it is my first real exposure to a C++ type language. However, I've been using shell script for over a decade, have a passing familiarity with PERL and have been teaching myself VBA recently. In short, I'm not a complete noob, although right now, I'm feeling like one! ![]()
So now onto the problem at hand!
Ultimate Goal: I'm attempting to creating some pulsing purple lights for a costume being displayed at the International Makeup Artists Trade show (IMATS) in May.
Hardware: To test the final look I'm aiming for I am currently using an Uno Rev3 (ATMEGA328 with 10 Adafruit NeoPixel LEDs cut from a strip. The LED's are connected to the Uno via the 5V and GND pins and data is provided via pin 6.
Current Goal: Rather than jump straight in at the deep end, I'm attempting to build the code from scratch so that I have a better understanding of exactly what is happening. As such, at the moment I am just attempting to turn all 10 LED's onto a single colour, red in this case. The code I am using for this is as follows:
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define PIX 10
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIX, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// put your setup code here, to run once:
strip.begin();
strip.show();
}
void loop() {
// put your main code here, to run repeatedly:
for(int i = 0; i<strip.numPixels(); i++) {
strip.setPixelColor(i,255,0,0);
strip.setBrightness(10);
strip.show();
}
}
Expected Output vs Reality: So, if I'm aiming for 10 red LED's from this code, I'm not even close!
LED's 1, 4 and 7 are red.
LED's 2, 5 and 8 are green. 2 and 5 also have their white side lit up.
LED's 3 and 6 are blue with white lit up.
LED's 9 and 10 are unlit.
Output can be seen here.
I should also add that I've tested the hardware configuration using the strandtest sketch that comes with the NeoPixel library. Output from that appears to be OK so I don't think I have a hardware issue.
So in short, what simple thing have I overlooked/gotten wrong in getting red LED's?