8bit Mix Tape: Difference between revisions
No edit summary |
|||
| Line 43: | Line 43: | ||
* add 1 button to PB02 (pin 7), on press to 5V - maybe needs to be optimized and debounced | * add 1 button to PB02 (pin 7), on press to 5V - maybe needs to be optimized and debounced | ||
* add speaker and mini-jack to PB0 (pin 5) | * add speaker and mini-jack to PB0 (pin 5) | ||
* add batteries incl. a on/off swith to VCC / GND | |||
==Parts== | ==Parts== | ||
Revision as of 07:02, 4 February 2013
Overview
The 8bit MixTape is an arduino compatible sound gadget, based on the Babygnusbuino (anyma) and Viznut's "Algorithmic symphonies from one line of code", put together by dusjagr, ucok and iyok...
Prototypes
v0.1

{{#widget:Vimeo|id=58727965}}
First version using a BabyGnusbuino attached to a card-board tape dummy
v0.2

{{#widget:Vimeo|id=58831051}}
New version, v0.2, nicely fits into a tape, with battery, USB programming interface, LEDs and a button to choose different codes.
What needs to be done
- make a cool video
- test the read/write head
- define size and specifics of parts (small potentiometers anyone?)
- design a PCB
- make more cool songs
Schematics
see Babygnusbuino for the USB / attiny85 stuff
New pin definitions file: File:Pins arduino.h.zip put in ./sketchbook/hardware/Gnusbuino/variants/attiny85
// ATMEL ATTINY85 / BABYGNUSBUINO // // +---\/---+ // !RESET (AD 0) PB5 1| |8 VCC // (D3/A3)PWM? PB3 2| |7 PB2 / USB+ // (D4/A2)PWM? PB4 3| |6 PB1 / USB- / PWM? // GND 4| |5 PB0 / D0 / PWM // +--------+ //
- add 2 potentiometers on PB03 and PB04 (that's the pin 2 and pin 3 on the chip)
- add 1 button to PB02 (pin 7), on press to 5V - maybe needs to be optimized and debounced
- add speaker and mini-jack to PB0 (pin 5)
- add batteries incl. a on/off swith to VCC / GND
Parts
Babygnusbuino Parts:
- 1 Atmel Attiny85 microprocessor
- 2 resistors 68 Ohms
- 2 zeners 3.3V
- 1 resistor 1k6
- 1 capacitor 100n
8bit MixTape:
- 1 potentiometer 20kOhm lin
- 1 potentiometer 10kOhm log
- 1 bushbutton (the flat ones that fit on a breadboard)
- 1 mini Jack with switch, 3.5mm (mono in v0.2, stereo comes later)
- 2 LEDs (smd or 5mm), including resistors as wished
- 1 mini-speaker
- 2 CR2032 batteries
- 2 clips for batteries
- 1 switch on/off
- 1 mini-USB connector (u can also make your own USB cable, scavenging or get a USB plug)
- (1 capacitor, 0.1 - 1µF for low-pass filter if needed)
- (1 read/write head for magnetic tape)
Links
http://youtube.com/watch?v=GtQdIYUtAHg http://wurstcaptures.untergrund.net/music/ http://wiki.sgmk-ssam.ch/index.php/Babygnusbuino
Code
8bit MixTape with button selector
/* Crazy shit 8-bit symphony generator */
/* */
/*
* inspired by:
* http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html
*/
int speakerPin = 0;
int buttonPin = 2;
int potiPin3 = A3;
int potiPin4 = A2;
int buttonState = 0;
int lastButtonState = 0;
int count = 0;
unsigned long int pulseWidthOFF = 0;
unsigned long int pulseWidthON = 0;
unsigned long int pulseWidthPart = 0;
int samplingDelay;
unsigned long int reg;
long t = 0;
int v = 0;
unsigned int c3 = 0;
unsigned int c4 = 0;
unsigned int analogValue;
void setup () {
TCCR0B = TCCR0B & 0b11111001;
pinMode (speakerPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode (potiPin3, INPUT);
pinMode (potiPin4, INPUT);
reg = 0x551155aaL;
}
void loop () {
// read the state of the switch into a local variable:
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState && buttonState == HIGH) {
// if the state has changed, increment the counter
count++;
t = 0;
delay(10000);
if (count > 5) {
count = 0;
}
}
lastButtonState = buttonState;
switch(count) {
case 0: // a classic
c4 = ((analogRead(potiPin4)>>6) + 1);
c3 = (analogRead(potiPin3)>>0);
v = (t*(t>>8|t>>4))>>(t>>c4);
analogWrite (speakerPin, v);
delayMicroseconds(c3>>2);
t++;
break;
case 1: // ding dong
c4 = ((1023-(analogRead(potiPin4))>>6) + 1);
c3 = (analogRead(potiPin3)>>0);
v = t * ((t>>15|t>>c4)&83&t>>(c4>>3));
digitalWrite (speakerPin, v);
delayMicroseconds(c3<<2);
t++;
break;
case 2: // experimental 8 bit
c4 = ((1023-(analogRead(potiPin4))>>6) + 1);
c3 = (analogRead(potiPin3)>>0);
v = t * ((t>>15|t>>c4)&83&t>>(c4>>3));
analogWrite (speakerPin, v);
delayMicroseconds(c3);
t++;
break;
case 3: // PWM modulation
c3 = (analogRead(potiPin3));
c4 = (analogRead(potiPin4) + 1);
pulseWidthPart++;
pulseWidthON = (c3 * pulseWidthPart / 255);
pulseWidthOFF = (c3 - pulseWidthON);
digitalWrite(speakerPin, HIGH);
delay(pulseWidthOFF);
digitalWrite(speakerPin, LOW);
delay(pulseWidthON);
if (pulseWidthPart == 255) {
pulseWidthPart = 254 - (c4>>3);
}
break;
case 4: //white noise
unsigned long int newr;
unsigned char lobit;
unsigned char b31, b29, b25, b24;
b31 = (reg & (1L << 31)) >> 31;
b29 = (reg & (1L << 29)) >> 29;
b25 = (reg & (1L << 25)) >> 25;
b24 = (reg & (1L << 24)) >> 24;
lobit = b31 ^ b29 ^ b25 ^ b24;
newr = (reg << 1) | lobit;
reg = newr;
digitalWrite (speakerPin, reg & 1);
samplingDelay = 1 + (2*(analogRead(potiPin3)>>0));
delayMicroseconds (samplingDelay);
break;
}
}