Arduino intermittent hang up?
Hey I'm working on a NeoPixel Arduino and Millumin integration with an Uno board. I've gotten the libraries to work and correctly trigger the digital pins, but every once in a while the pins don't read the data track from the the dashboard. About 1 in every 20-30 toggles, and it gets hung up for a few seconds up to 30 seconds before it corrects itself. Is there something I'm missing in the code?
#include <Adafruit_NeoPixel.h> #include <Arduino.h> #include <MilluminStream.h> // Which pin on the Arduino is connected to the NeoPixels? // On a Trinket or Gemma we suggest changing this to 1: #define LED_PIN 6 // How many NeoPixels are attached to the Arduino? #define LED_COUNT 16 // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800); int inten = 0; // Global instensity for sharing and cross fading effects void setup() { // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. // Any other board, you can remove this part (but no harm leaving it): Serial.begin(9600); MilluminStream:setup(); MilluminStream::setLoopIdleTime(16); pinMode(13, INPUT_PULLUP); pinMode(LED_BUILTIN, OUTPUT); strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(100); // Set BRIGHTNESS } void loop() { // First, we need to update MilluminStream MilluminStream::update(); int digPin13 = digitalRead(13); if (digPin13 == 1) { digitalWrite(LED_BUILTIN, HIGH); //rainbow(10); } else { digitalWrite(LED_BUILTIN, LOW); //pulseWhite(5); } MilluminStream::sendDigitalForID(13); // Finally we send just one frame with all our values MilluminStream::sendFrame(); } //... Rest of functions below don't affect the code.
Comments
Hello @whataweirdguy,
I see a first error in
MilluminStream:setup()
: it should beMilluminStream::setup()
Also,
LED_BUILTIN
is usually the pin 13, so in your program you are reading and writing at the same time, which is not a good practice. You should rather use a variable to do so, and MilluminStream can help you with this.Please check this project and this sketch that update a variable on both sides :
Best. Philippe
Thanks Philippe, I will give this a try and report back
Got the variables working. Love this option. Allows for many more triggers. But I am still getting the hung data like the previous version.
This is good enough for my immediate needs, but hoping to figure this out for other more sensitive projects down the road. May be by hardware on my side, so I will try different cables, etc.
Hello @whataweirdguy,
I just tested without any NeoPixels leds, and it works fine.
Please use my sketch above only, and let us know if the problem persists.
Best. Philippe