Therefore, I decided to remove the external oscillator and use the internal 8MHz oscillator.
To do this, you’ll need a programmer. I’m using a cheap USBASP bought from ebay.
To enable the internal oscillator, you’ll need to change the fuses on the ATmega328P. In PIC terms, it’s called the configuration bits.
Head on to http://www.engbedded.com/fusecalc to help you decide what fuse values to use.
Select ATmega328P and choose Int. Rc Osc. 8MHz (default value). Then proceed to uncheck divide clock by 8 internally.
It will return three sets of hex numbers for you to change using avrdude. Avrdude is a tool designed for flashing Atmel chips.
They are E2 D9 and FF. To avoid typing it wrongly in avrdude, they also generated the arguments for you to paste into the command prompt.
Fire up command prompt and type in the following command.
avrdude -c usbasp -p m328p -U lfuse:w:0xe2:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m
Ignore the last error that says the verification of the efuse has failed. Choose No when it’s asking whether to change back the fuse or not.
Now that you’ve flashed the fuse to use the internal oscillator, you can still use the Arduino IDE to program your ATmega328P.
Be sure to select “Upload using programmer”. Now your circuit will be much simpler.