Mini Computin

Just a useless toy. It’s a port of a program I once made for PC that was supposed to be a musical instrument you played with mouse: X axis = pitch, Y axis = volume.

Here you use the arrows obviously, X axis means pitch but since there’s no volume for ArduBoy (AFAIK) I made the Y axis affect tremollo. A button plays pin 1 only, B button plays both pin 1 and pin 2 simultaneously which creates kind of a flanger effect. The background is colored according to piano keys. It’s extremely difficult to play and completely useless, I just wanted to see how it would turn out. You can at least play around with the constants in the code and try to break it in various ways.

I tried recording a video but the sound couldn’t be heard :slight_smile:



Just to clarify a bit how this program differs from the usual piano applications and sequencers:

This one plays the whole continuous range of frequencies, not just predefined keys (C, D, E, F, G, A, B), which can be seen both as a feature (tone bending) and a complication (playing off key).


ArduboyTones can do 2 volume levels.

For more sophisticated volume (and waveform and polyphonic) control you can use pulse width modulation (PWM) as ATMlib and ArdVoice do.


This fits this part of GNU license header:

/*This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  GNU General Public License for more details.*/

I think maybe you can add letters (like C3) to the key (that plays C3), noobs like me (although I do know the fact that it is CDEFGAB but still) will be difficult at finding the right tone.

UP_BUTTON for louder and DOWN_BUTTON for quieter? could be arranged differently but that sounds good.

ArduboyTones can do 2 volume levels.

Is this any completely general way to work with audio on ArduBoy? I’ve been searching a bit and always found just libraries for playing tones etc. I don’t even know the hardware sound system - is it possible to e.g. use PCM or play a sample buffer? That would open many possibilities for this program.

This program is distributed in the hope that it will be useful

Well, that justifies the CC0 license I guess. If I used GPL, my description would be in conflict :smiley:

Although I’ve been jamming around a bit and after a while it seems quite fun, you know like a vuvuzela or something :smiley:

I think maybe you can add letters (like C3) to the key (that plays C3)

Thanks for suggestion, I’ll look into it. I’m used to playing piano so it didn’t even come to me, but I guess maybe guitar people could appreciate that.

1 Like

The Arduboy’s piezo speaker is simply connected across two digital I/O pins. These are Port C bit 6 (Arduino pin D5) and Port C bit 7 (Arduino pin D13).

Attaching the speaker across two pins, rather than fixing one pin to power or ground, essentially forms a mixer for the signals on each pin, creating a simple two channel system. (If you only want to use one of the pins, the other must be set to output low to create a return path for the signal.)

You can use a pre-written library that manipulates these pins or write your own functions or library that directly controls these pins.

In addition to using the pins as basic digital outputs, where you simply toggle them high and low directly as required, both pins can also be controlled by a timer/counter, which allows PWM. The pins can both be attached to Timer 4, in which case one pin will output the compliment of the other (for twice the voltage, thus higher volume). Pin C6 can alternatively be attached to Timer 3, allowing it to be controlled separately from whatever is being done with Pin C7.

Yes, it would be possible to use a sample buffer to modulate a timer in PWM mode. This is what the ArdVoice library does. ATMlib uses the same PWM technique but rather than reading a sample it dynamically creates the waveform that the PWM is to produce.

Note that there is no low pass filtering on the speaker, so it can end up sounding a bit “scratchy”. Fiddling with the timer settings can help with this somewhat.

1 Like


Just to let you know, the website lets you quote people by highlighting a section of their comment and then pressing the ‘quote’ button that appears.

I’m not sure how you’re doing it at the moment but you’re ending up with general quotes instead of targetted quotes, so the person you’re quoting won’t be notified.


Which results in:

[quote="drummyfish, post:4, topic:6142"]
I don’t even know the hardware sound system

Which shows up as:

And you get a notification about it.

1 Like

Never mentioned that I DO play gitar!

I think that is acceptable. Least I can. (as that is what happens after I plug my gitar into the Amp and turn up the distortion.)
Speaking of that… i guess ppl can tune the timer themselves (since there are people that like “clean tune” better than… say, “heavy metal”.)
Maybe simulating the different electronic instruments…erm…well this is essentially Square wave coming out of a piezo, slightly less pleasing to the ear. But who knows what it sounds like (never tried on arduboy yet)
Mmmm…this is sounding more USEFUL now…