Dev Kit Hardware

@bateske Having the speaker output on a PWM port would make a lot of sense if it’s still possible. Then a lot of the frequency modulation can be mostly done in hardware, not software.

1 Like

I second that strongly. I fully intend to focus on musical programming

The only reason I can think of: digital pin3 is on the other side of the chip, so the lane has to cross a lot of other lanes … unless it goes underneath the chip. BUT still If possible please do change: listen to tracker music in this post: 4 channel tracker music

I think one of the differences between the dev kit and the final release was that only a single layer for wiring is used on the dev kit to make it quicker and easier to produce. That would of course mean taking some shortcuts and switching some wires. So it’s certainly possible to have a better layout in the release hardware.

Please don’t use pin 3! That’s the clock line for I2C. I’m sure hackers would like to keep pins 2 and 3 free for attaching I2C peripherals.

Pin 6 is currently unused and is PWM capable…


I really hope so, because for music, and I don’t mean just tone generation, we need PWM

But before assigning a pin, we’ll have to check: 8/16 bit, timers and PWM. All music tests I have done, were on a Arduino Ethernet using Pin3 = (PCINT19/OC2B/INT1) PD3. Pin3 on the Leonardo seems to be an other kind of Pin3 = (OC0B/SCL/INT0)PD0

So the Squawk library isn’t usable out of the box, but … I guess it can be rewritten.

It’s hard to say with just a square wave for each tone. Someone would have to try it. I haven’t experimented with this myself.

Just oring the two is what my diode suggestion would have done, as well as my later suggestion to use an actual external or gate. And, (although it was a bad thing to do) I think that was the intent of just shorting the two pins.

Having the speaker on a PWM pin would certainly give us more options, as @JO3RI has demonstrated in this related topic.

is there an interrupt on Pin 6 ? mmm this is beyond my knowledge. Someone should look into the squawk library, ArduinoSynth or Wavetable Synthesis and see if it can be rewritten for one of the pins that won’t be used.

I just took a look at the Squawk library on GitHub. For the Arduino Leonardo (or anything ATmega32U4 based), they recommend using Pin 5.
From the code for the Squawk_player.ino sketch on GitHub:

Pin 5 is currently used for the Right Arrow button. If we want to move the speaker to a PWM pin then we’re already making the production version incompatible with the Dev Kit version. Therefore, moving the Right Arrow button to another pin, so pin 5 can be used for the speaker, should be acceptable.

Changes to the Arduboy library and/or existing sketches would be minor, but we would probably need separate Dev and production versions of them. They could use the same source files with just conditionally compiled sections based on a define


// Uncomment the following define for the Dev Kit version
//#define DEVKIT

#ifndef DEVKIT
  #define RIGHT 6
  #define SPEAKER 5
  #define RIGHT 5
  #define SPEAKER A2

…and if we’re shifting Pin assignments around… Arduino Button Mappings

Exactly, there is no need for separate sketches.

OK thanks @MLXXXp So now we have to convince @bateske to change pin connections !

Just a thought (after noodling about the PWM stuff).

Most piezo sounders are relatively high impedance and are, by design, capacitive devices. Could the piezo serve as both the sounder and the mixer?

The pins would never be directly connected, and since I doubt very much we are worried about phase, it doesn’t matter whether an output is direct or inverted.

If only one pin is cycling, the other pin is either source or drain, depending on the config. If both are cycling, you will get both frequencies.

1 Like

Yes, you could put each lead of the speaker on a separate output, but what’s the point? I assume you’re talking about the final toggling of the pins being done through software, not using PWM. If this is the case, then, as I’ve already said:

And if, for some reason, you really want the signals to be out of phase, you use an xor.

Thinking about this further, I guess having the ability to swing one lead low-to-high and the other high-to-low might offer better mixing and have an effect on volume. There may be some merit in doing this.

I think moving the speaker to a single pin with PWM capability would be of more benefit, though.

Software mixing two different frequencies exactly can be expensive. If just mushing the wires together gets that for us then that’s a better solution.

How do you play two tones at once then? Rapidly toggle the PWM frequency? I don’t know enough to be sure how this would work.

fourier transform is what you are after. It relates to the just intonation thread we were posting in yesterday.

Has anyone tried oring or xoring two square wave tones together on the same pin? It might be good enough.

Otherwise, use the same techniques as Squawk does. There’s already been a discussion about this.

Besides, do we really need to play two tones at once, considering the simple intent of the Arduboy, and that all the games I’ve seen for it so far just use single tones (many of them are pretty impressive).

1 Like

This thread has been tagged as a guide and likely was intended to provide details of the Dev Kit hardware, as the title implies.

With that in mind, I’ve created a new linked topic to discuss the design of the Arduboy that will be delivered to Kickstarter backers.