Here's a few examples for Arduino developed by the Dr (little-scale) and myself.
To run it you need an arduino, with an R2R DAC on PORTB pins 0 - 3 (i.e. digital pins 8, 9, 10, 11).
Here's an image to help you with the R2R DAC
I didn't follow that image in regards to R1 and R2, I just used a single value for everything.
Personally I used a piezo buzzer on the output, but you could put it through an amplifier or whatever you wanted.
void setup() {DDRB=B00001111;}
void loop() {for(long i=0;i<1000000;i++) {
PORTB = i / 3 >> (i % 40 + 5) | i / (24 + i & 3) >> (i % (15 - ((i >> 15) % 8) * 6) + 5);
}}
An example from the doctor-scale, with audio.
http://milkcrate.com.au/_other/useless/
r_%234.mp3
And it's tweetable.
http://twitter.com/#!/littlescale/statu
7984927744
void setup() {DDRB=B00001111;}
void loop() {for(long i=0;i<100000;i++) {
PORTB = i / 3 >> 1 | i / 2 >> 2 & (i / 5) >> 7 | i & 31 * i * (i >> 8);
}}
void setup() {DDRB=B00001111;}
void loop() {for(long i=0;i<100000;i++) {
PORTB=i/152>>(i%(i/9939))|((i%5)>>(17*15));
}}
void setup() {DDRB=B00001111;}
void loop() {for(long i=0;i<100000;i++) {
PORTB = i / 7000 >> (i % (i/5)) | i / (24 + i & 6300) >> (i % (137 - ((i << 15) % 8) >> 6) + 5);
}}
void setup() {DDRB=B00001111;}
void loop() {for(int i=0;i<100000;i++){
PORTB=i/70>>(i/7<<(i/8))<<i*9%(24+i*30)>>18766*(i*5%4);
}}
void setup() {DDRB=B00001111;}
void loop() {for(int i=0;i<100000;i++) {
PORTB=i/992>>(i%(i/939))<< (i*i*i)>>((i<<5)>>(17/i));
}}
void setup() {DDRB=B00001111;}
void loop() {for(long i=0;i<100000;i++) {
PORTB=i/12>>(i%(i/939))%((i%93)>>(17*3));
}}
Basically just play around with numbers, "int" and "long" can be changed for varying sounds.
Last edited by godinpants (Oct 1, 2011 10:48 am)