Hi, I'm new here - please forgive me and redirect me if I'm broken any protocols! I'm reasonably familiar with Arduino, but am new to ICSP programming an ATmega328P in my own circuit.
The short version of my problem is that I can use ICSP, using an Arduino as an ISP to burn the bootloader, and then upload "blink" to my ATmega328P, but when I try to load more complex code, such as "Hello World" from the "Liquid Crystal I2C" library, the upload doesn't work. I get "avrdude error: cannot open port \.\COM3: Access is denied". I've tried all the usual stuff like restarting the IDE, disconnecting and reconnecting the Arduino from my computer, using a different USB port etc.
Details:
My circuit is as follows:
Schematic_Magnetic-Field-Sensor-I2C-Sensor_2023-08-27.pdf (91.9 KB)
I connect it as follows to a CH340 Arduino Uno, set up as an ISP:
Arduino D10 to ATMega328P Pin 1 (reset)
Arduino D11 to ATMega328P Pin 17 (MOSI)
Arduino D12 to ATMega328P Pin 18 (MISO)
Arduino D13 to ATMega328P Pin 19 (SCK)
Arduino 5v to 5v rail of ATMega328P circuit
Arduino GND to GND rail of ATMega328P circuit
I won't go into all the details and steps (unless someone says that would be useful), but essentially, I am able to upload the Arduino as ISP code onto my UNO, then, using "MiniCore" , I am able to burn the bootloader onto my ATmega328, and I can also upload the stock-standard "blink" example code. But when I try to upload the following code (or my own code, which I haven't listed here because it is longer) I get the "avrdude error: cannot open port \.\COM3: Access is denied" error.
Any help would be greatly appreciated!
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("Hello, world!");
lcd.setCursor(2,1);
lcd.print("Ywrobot Arduino!");
lcd.setCursor(0,2);
lcd.print("Arduino LCM IIC 2004");
lcd.setCursor(2,3);
lcd.print("Power By Ec-yuan!");
}
void loop()
{
}

