Got something weird going on with a neopixel project and a Arduino Micro.
Code runs, emulates keystrokes as intended but upon the first power up the neopixel goes full white. Jumper the reset pin and the next time the code runs the pixel is correct. I have added an additional .1uf across the led +/- and a 470 Ohm on the data line. I have looked at both scenarios on the scope and nothing is jumping out. I also added a 10uf across vin just because. Neopixel is being powered via the usb 5v not the micro regulator.
#include "Keyboard.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define NeoPIN 6 // Pin connected to neopixel
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, NeoPIN, NEO_GRB + NEO_KHZ800);
const int buttonPin = 4; // input pin for pushbutton
int previousButtonState = HIGH; // for checking the state of a pushButton
int counter = 0; // button push counter
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
// initialize control over the keyboard:
delay(1000);
pixels.begin();
pixels.clear();
pixels.setPixelColor(0, pixels.Color(255, 255, 255));
pixels.show();
Keyboard.begin();
}
void loop() {
pixels.clear();
pixels.setPixelColor(0, pixels.Color(0, 50, 0));
pixels.show();
if (digitalRead(buttonPin)== 0) {
pixels.clear();
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
pixels.show();
Keyboard.print("~");
delay(200);
}
}
Any ideas?