Error resetting on atmega328PB

hello. I'm making an LED board using ATmega328pb. It is a simple board that turns on the LED just by entering a command such as 'r10g10b10' through serial communication, but there is a problem. I confirmed that the COM port was recognized and the connection was not disconnected, but sometimes there is an error that the board resets itself and returns to the initial value (when reset, the Com port does not disconnect at all and maintains the connection. However, as the board is initialized, Return to the Void Setup step). It occurs most frequently when receiving a command or uploading a program, but the cause is unknown, so we are checking it. Below is a picture of my board and when the error occurred. I would be grateful if you could check it out and let me know the solution.



What board did you select in the IDE for the upload?

This is my Code and IWS-L5056-RGB-K3 9 LEDs were used. Thank you.

#include <EEPROM.h>

void setup() {
  Serial.begin(9600);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);
  int a = EEPROM.read(0);
  int b = EEPROM.read(1);
  int c = EEPROM.read(2);
  analogWrite(5, a);
  analogWrite(6, b);
  analogWrite(9, c);
}

void loop() {
  char i;
  long x = 0;
  long y = 0;
  long z = 0;
  long w = 0;

  if(Serial.available()>0){
  i = Serial.read();
  
  if(i == 'r'){
   x = Serial.parseInt();
  if(x >= 0){
  analogWrite(5, x);
  EEPROM.write(0, x);
  }
  }
  if(i == 'g'){
   y = Serial.parseInt();
  if(y >= 0){
  analogWrite(6, y);
  EEPROM.write(1, y);
  }
  }
  if(i == 'b'){
   z = Serial.parseInt();
  if(z >= 0){
  analogWrite(9, z);
  EEPROM.write(2, z);
  }
  }
  if(i == 'w'){
   w = Serial.parseInt();
  if(w >= 0){
  analogWrite(5, w);
  analogWrite(6, w);
  analogWrite(9, w);
  EEPROM.write(0, w);
  EEPROM.write(1, w);
  EEPROM.write(2, w);
  }
  }
}
}

I received the program dedicated to atmega328pb from Github and used it. In this way, the program usually starts up normally, but sometimes the error in the picture attached above occurs due to the symptoms of initialization.

did you tested this chip before soldering? did you uploaded proper bootloader?

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