Pin 6 Used as Volume Booster

pin 6 Confirmed to work as volume booster using an adapted version of ATMlib using pin 5 and 6 for audio :smiley:

So I’ve adapted my pinout table accordingly:

Arduboy function Arduboy / Leonardo / Micro DevKit Pro Micro 5V std. Pro Micro 5V alt.
OLED CS 12 PORTD6 6 PORTD7 GND 1/TXO PORTD3*
OLED DC 4 PORTD4 4 PORTD4 4 PORTD4 4 PORTD4
OLED RST 6 PORTD7 12 PORTD6 6 PORTD7 2 PORTD1*
SPI SCK 15 PORTB1 15 PORTB1 15 PORTB1 PORTB1
SPI MOSI 16 PORTB2 16 PORTB2 16 PORTB2 PORTB2
RGB LED RED 10 PORTB6 _ 10 PORTB6 10 PORTB6
RGB LED GREEN 11 PORTB7 _ 3 PORTD0*
RGB LED BLUE 9 PORTB5 17 PORTB0 9 PORTB5 9 PORTB5
RxLED PORTB0 _ PORTB0 PORTB0
TxLED PORTD5 _ PORTD5 PORTD5
BUTTON UP A0 PORTF7 8 PORTB4 A0 PORTF7 A0 PORTF7
BUTTON RIGHT A1 PORTF6 5 PORTC6 A1 PORTF6 A1 PORTF6
BUTTON LEFT A2 PORTF5 9 PORTB5 A2 PORTF5 A2 PORTF5
BUTTON DOWN A3 PORTF4 10 PORTB6 A3 PORTF4 A3 PORTF4
BUTTON A (left) 7 PORTE6 A0 PORTF7 7 PORTE6 7 PORTE6
BUTTON B (right) 8 PORTB4 A1 PORTF6 8 PORTB4 8 PORTB4
SPEAKER PIN 1 5 PORTC6 A2 PORTF5 5 PORTC6 5 PORTC6
SPEAKER PIN 2 13 PORTC7 A3 PORTF4** GND 6 PORTD7*

*Alternate pins for Pro Micro 5V requires homebrew package, **do not configure as output on DevKit.

5 Likes

So you are saying that Micro, Leonardo, Leonardo ETH and Arduboy have the same wiring?
The MEGA sounds good with a immense onboard storage. Any knowledge on its wiring?

They don’t have the exact wiring. But the pins that are used by Arduboy are. I wouldn’t recommend using an Leonardo ETH, there may be a conflict with the SD card and Ethernet hardware

Half of the reason I want to use the ETH is because it is “historical” in it being retired (and I can still get my hand on) and that is what the Arduino IDE see the Arduboy as. But that is the same price as a manufactured Arduboy so I kind of not want to do it.
I am just curious about the PINs, as the chart above (somewhere) list them in one column.
I am GOING to create a Arduboy clone. I am currently considering NOT a micro or a micro pro. Boards listed by you are awesome choices as no changes need to be done. I am thinking maybe a Esplora, a Mega2560, Leonardo or Leonardo ETH.
Esplora was too unflexible, and buying a already-made gameboy costing more without a case and a screen is not what I am going to do.

The main reason for getting a Leonardo ETH would be if you want to use the ethernet part of it. I had a quick glimpse at thje schematic and noticed something that makes it not suitable for a selfmade Arduboy:
pin PD4 which is used for OLED DC (OLED data/ command select) on Arduboy is used as SD card select on the Leonardo ETH.

The MEGA doesn’t use an ATMEGA32U4 as MCU so there may be software issues to deal with.

1 Like

many pins that have to be changed in the core library I presume, if want to use the pro micro :frowning:. That mean it also will incompatible with hex/arduboy file

1 Like

The vast majority of games are open source anyway, so that doesn’t really matter much.
You can just change them to use your modified library and then compile them as normal.

2 Likes

yup, I guess it might be wont be very much a problem if you are DIY enthusiast since arduboy is a learning tool itself and make the user get used to coding

Hi, Thanks a lot for the Arduboy-homemade-package.

It uses Pin 5 and 6 as audio out. I want to use a common grounded audio out so that I can share the same speaker in the circuit to use with my other sound sources.

Would you please point me to the code which needs to be modified to freeup pin 6.

Thanks in advance.

You would be best to come up with some sort of mixer circuit that mixes the two pins plus your additional sound source(s) to drive one speaker pin, with the other pin grounded.

1 Like

do you want to free-up pin 6 for another function or just want to ground your speaker?
in the last case you can just connect your speaker between pin 5 and ground.

However If you’re going to hook both your Arduboy clone and another device to the same speaker pin, you need to have some protection from the pins shorting each other (one device output low, other device high or vice versa will cause a short)

if you’re using a piezo speaker adding a 1K resistor at each device output would be fine. If you’re using an actual (low impedance) speaker you’d better drive the speaker pin using a transistor (each device drives a transistor, so you need two)

Thanks @Mr.Blinky for the reply.

I want to ground one of the speaker pins to make it compatible with my other audio sources. My plan is to add an FM receiver and MP3 player in the same enclosure along with Arduboy. In future, I might also want to add some sensors or want to control any other gadget from the same MCU, hence freeing up a pin or two will be convenient.

I am not sure how the current audio implementation of Arduboy works with 2 pins; At first, I assumed one pin is used for generating tones and the other pin is used for controlling volume level. Or there may be a complex audio generation by using both pins as different frequency generator.

I have just started learning MCU and embedded C, and mostly learning by practical experimentation. Understanding the code base is difficult and time consuming for me as I have to grab many new concepts on the fly. Wish there were some content describing the Arduboy codebase and hardware.

After reading reply from you and @MLXXXp, I am thinking of trying a single transistor adder ckt as below:

In 1 ------\/\/\/------|. . . . . . |/--------- + Vcc
In 2 ------\/\/\/------|----------|
In 3 ------\/\/\/------|. . . . . . |\>------- Out/Spk +

In the Arduboy, one pin is connected to one of the speaker leads. The second pin is connected to the other speaker lead, rather than grounding this speaker lead.

Since each pin can sink as well as source current, you can leave one pin low (or high) and it will provide a return path for a signal generated on the other pin. (Therefore, note that in order to hear sound generated from one pin, the other pin must be set as an output.)

As a side note: The piezo speaker used is essentially a capacitor, so you can’t damage anything by having one pin permanently high and the other permanently low. It will just “charge” the speaker/capacitor. (If you were to use a low impedance “voice coil” type speaker with this arrangement, you would need a suitable capacitor in series with the speaker to block any DC component of the signal.)

Now, if an audio signal is put on one pin and another audio signal, with the phase reversed, is put on on the other pin, it ends up mixing the two signals. This allows a single speaker to play two distinct audio signals, the same as if the signals had been mixed by some other method. The ArduboyPlaytune library uses this to allow playing a two part score with each part on a pin, or a single part score on one pin while outputting tones on the other pin.

Another thing the circuit is capable of: If you place identical signals on each pin but with one having a reversed phase to the other, you will get a higher volume than if one pin was held constant. (The voltage on the speaker will be doubled.) The ArduboyTones library uses this technique to allow any tone to be played at either “normal” or “louder” volume.

1 Like

As I described in my post above, if you plan on mixing the two pins from an Arduboy compatible, the signal from one of the pins should be inverted (phase reversed), and possibly capacitively or AC coupled, which is what attaching the two pins directly to a piezo speaker does.

Thanks for the details.

What is this about pin 6 is there reference to the thread how this is implemented? How is it louder?

This topic is initially about @Mr.Blinky reporting that Aruduino Pin 6 can be used to replace Pin 13 (used by the Arduboy along with Pin 5 for the speaker) to output the compliment of Pin 5, for higher volume. The reason for using Pin 6 is that Pin 13 isn’t available on the Sparkfun Pro Micro board, which many people use for making Arduboy “clones”.

Pin 6 doesn’t provide anything that can’t be done with Pin 13 on a real Arduboy.

You get a louder volume by driving one speaker pin high whenever the other pin is low, as compared to just leaving one pin fixed low or high. It doubles the voltage of the waveform presented to the speaker. As I stated earlier in this thread:

ATMlib and ArdVoice also use it permanently because the PWM generated waveforms they produce tend to be lower average volume than what you get from simple square wave tones.

@MLXXXp I used following ckt. As you suggested for coupling, I added cap in series of each audio in. Do you think it is okay?

In 1 -----||------\/\/\/------|. . . . . . |/--------- + Vcc
In 2 -----||------\/\/\/------|----------|
In 3 -----||------\/\/\/------|. . . . . . |\>------- Out/Spk +

C=0.1uf R=~1K, T=2SC828

What if I take output from Pin 5 or 6 only? If Pin 5 and 6 gives inverted signal, I guess using one pin will affect only in loudness. Or those pins provide sound of different instrument also?

Yes. For full compatibility, you need both pins and one should be inverted.
Sometimes only one pin is used.
Sometimes only the other pin is used.
Sometimes both pins are used with different sounds on each.
Sometimes both pins are used with one being the compliment of the other for higher volume.

Also, using the transistor as a simple saturated switch for PWM digital signals, with full swing, might be okay but if any of your sources are true analogue signals you’ll probably need to bias the transistor as a true amplifier or use some other analogue amplifier circuit.

As for the capacitor and resistor values, you may have to experiment to determine what’s best.

1 Like

Thanks a lot for the details. :hugs: