I resolved the issue ![]()
#simplex, you were right about the fact, that the error was caused by wrong ISP connections.
Thank you for the help!
The final solution was as follows:
-
Load the MegaISP sketch to the first Arduino Uno used as the ISP programmer. The sketch is also included as an example in the Arduino IDE, under the name "ArduinoISP".
-
Connect this Arduino to the Arduino you want to program. The connections are as follows:
Connect programmer pin 10 to the targets ICSP Reset header
Connect pin 11 to MOSI
Connect pin 12 to MISO
Connect pin 13 to SCK
The ICSP header connectors is shown below:

The VTG and GND pins on the ICSP header is not used.
When using the Arduino Uno an 10uF capacitor has to be connected between RESET and GND, as described in the ArduinoISP tutorial
The final schematic should be as shown below:

- Connect the programmer-Arduino to the computer, open Terminal/the commando promt and type the following command:
avrdude -p m16u2 -F -P /dev/cu.usbmodem621 -c avrisp -U flash:w:HIDUINO_MIDI.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m -b 19200
'/dev/cu.usbmodem621' should be replaced by the port, your Arduino is connected to. [/li] - You're done