Thanks for the help, guys! I really appreciate it.
I've cut the last data out pin on my board so it shouldn't be grounded. Thank you for pointing that error out. I can't recall why I did that.
What pull up resistor value would you recommend for the reset pin? 1K?
The atmega needs a pullup on the reset line and local bypass caps at each pair of power pins. I don't see any +5V connections to the micro, but I'm guess you're using the top side copper pour for that?
Yup, I'm using the top copper pour for power and the bottom for ground.
What steps have you taken to initialise the neo-pixels? I have found that most often they will power-up in totally off state, but there is no guarantee. They can and do power-up in any state. Try holding the data line low for at least the reset period of 50uS.
Thank you, Andy. I've added my code below so you can see how I initalise them. How could I hold data line low for 50us reset period? .
//what is this bit doing?
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 12
// How many NeoPixels are attached to the Arduino?
#define NumPixels 6
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NumPixels, PIN, NEO_GRB + NEO_KHZ800);
const int BtnTrigger = 9;
const int BtnColourMode = 10;
const int BuzzerPin = 8;
int BtnTriggerState = 0;
int BtnColourModeState = 0;
int LastBtnTriggerState = 0;
int LastBtnColourModeState = 0;
int colour;
unsigned long timer = 0;
uint32_t white = pixels.Color(100, 100, 100); // 0
uint32_t magenta = pixels.Color(100, 0, 50); // 1
uint32_t red = pixels.Color(100, 0, 0); // 2
uint32_t orange = pixels.Color(100, 50, 0); // 3
uint32_t yellow = pixels.Color(100, 100, 0); // 4
uint32_t green = pixels.Color(0, 100, 0); // 5
uint32_t cyan = pixels.Color(0, 100, 50); // 6
uint32_t blue = pixels.Color(0, 0, 100); // 7
uint32_t purple = pixels.Color(50, 0, 100); // 8
uint32_t off = pixels.Color(0, 0, 0); // 9
uint32_t colourMode[10] = {off, white, magenta, red, orange, yellow, green, cyan, blue, purple};
void setup(){
pinMode(BtnTrigger, INPUT);
pinMode(BtnColourMode, INPUT);
pinMode(BuzzerPin, OUTPUT);
pixels.begin(); // This initializes the NeoPixel library.
}
void buzzer(){
digitalWrite(BuzzerPin, HIGH);
delay(50);
digitalWrite(BuzzerPin, LOW);
}
void trigger(){
buzzer();
delay(5000);
for(int i = 0; i < NumPixels; i++){
pixels.setPixelColor(i, colourMode[colour]);
pixels.show(); // This sends the updated pixel color to the hardware.
}
delay(20000);
for(int j = 0; j < NumPixels; j++){
pixels.setPixelColor(j, colourMode[0]);
pixels.show(); // This sends the updated pixel color to the hardware.
}
}
void colourSelect(){
buzzer();
if (colour < 9){
colour++;
for(int k = 0; k < NumPixels; k++){
pixels.setPixelColor(k, colourMode[colour]);
pixels.show(); // This sends the updated pixel color to the hardware.
}
}
else {
colour = 0;
}
delay(50); // Debounce
}
void loop(){
int BtnTriggerState = digitalRead(BtnTrigger);
int BtnColourModeState = digitalRead(BtnColourMode);
if (BtnTriggerState != LastBtnTriggerState) {
if (BtnTriggerState == HIGH) {
timer = millis();
colourSelect();
}
else if(timer >= 1000){
//Millis wait a second after the button has been pressed
//when the button is pressed, t_i= 0. Turn off after t_f = 1000ms
for(int l = 0; l < NumPixels; l++){
pixels.setPixelColor(l, colourMode[0]);
pixels.show();
}
}
}
if (BtnColourModeState != LastBtnColourModeState) {
if (BtnColourModeState == HIGH) {
trigger();
}
}
delay(50); // Debounce
LastBtnTriggerState = BtnTriggerState;
LastBtnColourModeState = BtnColourModeState;
}