Running OPL2 Audio Board Example Code on the OPL3 Duo - DhrBaksteen/ArduinoOPL2 GitHub Wiki

The OPL3 Duo board is backward compatible with the OPL2 Audio board. However with the current hardware and software there are two simple steps that you need to go through before the OPL2 Audio Board examples will work on your OPL3 Duo.

1. Constructor

The OPL2 Audio board has different default connections from the OPL3 Duo. Therefore we must change the pinout when we create the OPL2 library instance to tell the library we're going to be using different pins.

Hardware solution

If you rather leave the code as is then you need to change how some of the OPL3 Duo pins are connected the the Arduino. Two pins are swapped:

  • /IC is connected to Arduino pin 8
  • A0 is connected to Arduino pin 9
  • All other pins remain the same, no software changes are needed

Software solution

If you want to keep using the OPL3 Duo pinout, for example because you connect the board with a ribbon cable with a fixed connector, then you need to make a small change to the example code. In every example you will see the following line of code:

OPL2 opl2;

This creates an instance of the OPL2 library with the default pinout. To make it work with the OPL3 Duo pinout we replace this line as follows:

OPL2 opl2(9, 8, 10);

Now you can connect the OPL3 Duo board as you usually would.

2. Address lines

There are two address lines, A1 and A2, that the OPL2 Audio Board does not have. Therefore we must put these line into a fixed state if we want to run the OPL2 Audio Board examples as to not 'confuse' the OPL3 Duo.

Hardware solution

The simplest way to do this is to connect both the A1 and A2 line to GND. No code changes are needed and you can use the two free Arduino pins for your project.

Software solution

You can also fix it in the software, but then you must keep A1 and A2 connected to the Arduino. In that case you add the following lines of code above OPL2.begin(); in the setup() function of the example:

setup () {
	pinMode(7, OUTPUT);
	pinMode(8, OUTPUT);
	digitalWrite(7, LOW);
	digitalWrite(8, LOW);
	
	opl2.begin();

This has the same effect as the hardware solution, but it keeps the way the OPL3 Duo is connected the same.