Error when uploading sketch on Arduino UNO

Hello!
I’m using an Arduino UNO development board to program my ATM328.
My project consists in entering a number on the keypad and send it through an RF emitter. Obviusly, there’s an LCD interface.
While I tested the project in the UNO board, it worked perfectly. The I made my own PCB and the microcontroller never worked fine.

When I want to program the micro, this message appears:
avrdude: verification error, first mismatch at byte 0x01c5
0xd1 != 0xc1

(or sometimes, avrdude: verification error, first mismatch at byte 0x00bf
0x10 != 0x00)

I have another ATM328, which I programmed correctly and used perfectly in my own PCB, thus I think the problem is not there, but in the microcontroller. If anyone may have an idea of what the problem could be, I’d be really grateful.

Thanks in advance!

PS. Here’s the code

#include <Keypad.h>
#include <Wire.h>                 
#include <LiquidCrystal_I2C.h>
#include <RCSwitch.h>  

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  //LCD adress
RCSwitch mySwitch = RCSwitch();

unsigned long n=0;
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {1,2,3},
  {4,5,6},
  {7,8,9},
  {'*',0,'#'}
};
byte rowPins[ROWS] = {11, 10, 9, 8};   //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5};         //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


void setup(){ 
   
  mySwitch.enableTransmit(1);           //Transmitter is connected to Arduino Pin #1 
  mySwitch.setPulseLength(365);         //Optional set pulse length.
  mySwitch.setProtocol(1);              //set protocol (default is 1, will work for most outlets) 
  lcd.begin(16,2);                      //Display initialization
  
}

void loop(){
  
  lcd.setCursor(0,0);                   //Locate cursor
  lcd.write("Ingresar numero");
  
  char key=keypad.getKey();             //Get keypad number
  lcd.setCursor(0,1);
  if(key){                              //If key is pressed, write number on display
    if(key!='#'&&key!='*'){             //Write only numbers
      n=10*n+(key);
      lcd.print(n);
    }
    
  }
  if(key=='#'){                         //Key # is data reset.
    n=0;
    lcd.setCursor(0,1);                 //Relocate cursor
    lcd.clear();                        //Clear display
  }

  if(key=='*'){                         //Send data through RF Tx
    lcd.clear();
    lcd.setCursor(4,0);
    lcd.write("Enviando");
    mySwitch.send(n, BIN);              //It is sent few times to reassure it'll be received
    delay(25);
    mySwitch.send(n, BIN);
    delay(25);    
    mySwitch.send(n, BIN);
    delay(25);    
    mySwitch.send(n, BIN);
    delay(25);
    mySwitch.send(n, BIN);
    delay(25);
    delay(500);                         //This delay is for the user to see the message
    lcd.setCursor(0,1);
    lcd.print(n);
  }

}

santamaria14: While I tested the project in the UNO board, it worked perfectly. The I made my own PCB and the microcontroller never worked fine.

When I want to program the micro, this message appears: avrdude: verification error, first mismatch at byte 0x01c5 0xd1 != 0xc1

(or sometimes, avrdude: verification error, first mismatch at byte 0x00bf 0x10 != 0x00)

Sounds like an electrical problem to me. Are you sure you put enough decoupling capacitors in your circuit?

Yes, show your schematic. Could also be an interference problem on the serial lines. The chip you are downloading into has been bootloaded and the fuses set correctly?