Loop stops after a while

I've built my own arduino uno clone from a breadboard tutorial but used glassculptures and wire instead of a breadboard, so this could be a hardware problem but I don't think so, have checked it very carefully.

I want a regular blink on pin 9 and a fading of 4 neopixles on pin 11.
All works good, but the fading stops after a while (sometimes 2 hours, sometimes 15min...)
It stops in a random brightness (I think?) and stays there. The blink on pin 9 keeps gooing fine.
Could someone please check my code if there is something in it that could cause this?
Im not a good programmer at all.... Hope someone can help me, thank you so much.

#include <TimerOne.h>                //hjärtat
#include <Adafruit_NeoPixel.h>  //lungan

#define PIN 11                              //lungan

const int heart = 9;                     //hjärtat

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, 11, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit... if you must, connect GND first.



void setup() {
  
                                                         //lungan:
  strip.begin();
  strip.show();                               

  
                                                        //hjärtat:

pinMode(heart, OUTPUT);

Timer1.initialize(1000000);         //hur snabbt hjärtat slår 15
Timer1.pwm(heart, 70);              //hur länge varje slag lyser


}

void loop() {



                                                     //lungan:
  
  brighten();
  darken();
}

// dimrar upp från ljusstyrka 10 (25) till 255
void brighten() {
  uint16_t i, j;

  for (j = 10; j < 255; j++) {
    for (i = 0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, j, j, j);           
    }
    strip.show();
    delay(20);                                     //tid stannar i upplyst läge ? tid att dimra? 20
      Serial.println(j);
  }

  delay(50);
  
}

// dimrar ned från 255 till 10 (25)
void darken() {
  Serial.begin(9600);
  uint16_t i, j;

  for (j = 255; j > 10; j--) {
    for (i = 0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, j, j, j);                //kall vit i, j, j, j
    }
    strip.show();
    delay(20);
    Serial.println(j);
  }
  delay(900); //?




}   

How did you ever get this Serial.println(j); to work when you did set up serial begin in setup()?

Anyways:

First what does loop stops after a while mean? To figure that out a bit more info is needed.

In void setup() add in Serial.begin(115200); Set your serial monitor to the same baudrate.

In loop()

void loop() 
{  
Serial.println(  "a" );
  brighten();
Serial.println(  "b" );
  darken();
}

When loop stops we can see if a or b is the last thing printed. Now we know more.

In

If you are asking me:
The program seems to run like it should, the LEDs work like I wanted them to. But after some time (differs how long) only the LED on pin 9 keeps going and the fading LEDs (pin 11) stops fading but are lit. After a restart everything "works" again.

If it was a retorical question:
You can't see anything contradictory straight away in the code? (sorry english is not my best language if that's not the right word). So do I get you right that you suggest I fix the serial monitor thing so I get some information on what happens when it "stops"? Why I ask if you can't see anything contradictory straight away is because I hoped you could, because I can't connect to serial monitor anymore (in an easy way). Offcourse I will do it if it is the solution. But it will need a lot of crazy unsoldering since the "Arduino" is a glass installation now: how the DIY-arduino looks

haha I didn't.. :stuck_out_tongue_closed_eyes: I don't know what happens in the serial monitor, it didn't work when I checked (offcourse).

Thank you for your help! Let me know if you think unsoldering the glasscirquitboard is the way to go.. :sweat_smile:

Is that photo of a working Arduino Uno? In glass? WOW! Love it! Art and electronics in the same object.

Can you upload the photo here please for all to see?

Sorry for a very late update. And thanks for input.
I got it to work by doing three things:
-clearing out some junk from the code, like suggested
-using a watchdog library
-and most important to make it work perfect disconnecting the analogue reference (hardware)

Here is a picture and a video link

Video (Instagram)

Edit: I also did the neo pixels run from a separate voltage supply instead of directly from the Arduino pins. Not sure if it made a difference. But I just remembered I tried it and kept it like that since it worked in combination with the other edits.

1 Like

Lovely picture, can't view the video as it wants me to log in.

nice picture

could you please upload a video to youtube?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.