Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum
The easiest way is to use Edit/Copy for Forum in the IDE and paste it here. Code tags will automatically have been added
As to your problem, which Processor have you got selected in Tools/Processor in the IDE ?
Try the other ATMega 328P option