For my computation studio class i built a minimal synthesizer using arduino . I tried to incorporate ideas such as microtonality (tones/pitches bewteen pitches for example the pitches in between b and c) and binary as a way to add slight shifts to the pitches generated. I have 6 switches and each switch has a value they range from 160,80,40,20, and 10. Depending on which switches are on you will add its value to the pitch you hear. So if you are generating a pitch of 600hz and you have switch one on it will add 160 to that, and you will hear 760 hz. When you turn this switch off you will hear 600 again. If you have all switches on the sum of all the switches will be added to the pitch you hear. This project needs some electronics building and coding to get it to work and  i will share both here.

heres a bit about binary courtesy of wikipedia:

The binary numeral system, or base-2 number system, represents numeric values using two symbols, 0 and 1. More specifically, the usual base-2 system. Owing to its straightforward implementation in digital electronic circuitry using logic gates, the binary system is used internally by all modern computers.

http://en.wikipedia.org/wiki/Binary_numeral_system


finger binary:

i learned how to count like this a while ago, it’s what made me think about using switches to add to the pitches made by the arduino. Using this you can count really high using only your two hands.

http://en.wikipedia.org/wiki/Finger_binary


what you need for the electronics:

7 x spst (single pole single throw switches, you could use double pole double throw if thats what you have, you will only need 2 poles to get the switches to work correctly)

1 X 2.1 mm dc adapter plug ( i got some from radio shack)

1 X battery snap

1 X 9 volt battery

1 X arduino board ( i used a Duemilanove , there are many other types of arduinos out there)

2 X 100k potentiometers ( i used audio taper, linear taper should be fine too)

Wire ( as much as you can find, i have a wild wiring style maybe you will use less, You should try to get red and black wire and maybe some colors )

an enclosure if you want to make things more permanent.

Schematics:

with electronics everything can be broken down into smaller circuits. Your tv for example is really a collections of different circuits which are linked together, each section or circuit does its job and works together with the other circuits to get something done. This project is no different there are smaller circuits that when put together make up the whole. And so i will break this project down into its parts.

First:

Switches:


here is a photo to help visualize.

First is the schematic  for how the switches and potentiometers should be wired. Each switch has a connection to +5 and to ground, they also have a wire that will connect to the arduino. on one terminal of the switch solder a wire, I used red for +5. On the other terminal solder one of the 15k resistors, then solder a wire to the resistor this wire will connect to ground. Also solder the third wire to the same terminal you soldered the resistor to. When you turn the switch on the arduino will see the switch as being HIGH or on.

here is a simplified version of the switch wiring. To connect all 6 switches you would need to make this three time and connect all +5(red wires) together, and all ground(black wires) together.

here is photo of a potentiometer and how it can be wired to ground and +5:

here the blue wire connects to +5, and the yellow wire connects to ground while the wire connected to the center lug on the potentiometer connects to an analog pin on your arduino. You would need to repeat this with another potentiometer. You can connect the +5 and ground wires of the second potentiometer to the same +5 and ground points as the first.

power:


This is the schematic for the power portion of the project, here i am using a 9volt battery connected to a 2.1 mm dc plug to power the arduino without it being connected to a computer all the time. The led is used to indicate that there is power, you have to attach a resistor to the longer leg ( +) this leg is connected to the + side of the battery( the red wire).The shorter leg can go to the  - side of the battery. When you flip the switch the  led should light and you will have power going to your arduino.

here is a photo, it does not have an led . With or without an led it works the same.

here is a link to the tutorial at the arduino site on how to make this adapter:

http://www.arduino.cc/playground/Learning/9VBatteryAdapter

sound:


This is a schematic of the audio out portion, connect a 22o ohm resistor to one side (use a smaller resistor for higher volume, or use a larger resistor for less volume) of the speaker, I used a piece of wire then soldered the resistor to the wire to allow for some flexibility. The resistor is what you will plug into arduino. To the other side of the speaker solder a wire, this wire will go to ground.

here are some photos of the circuit plugged into the arduino:

Complete circuit:
Here is a schematic of all three parts put together. You see from left to right, the switches, potentiometers then the speaker.
CODE:

//This code uses the tone library its included with arduino 18,
//by:Bryant Davis
//created april 2010
//modified may 2010
/*
one sensor controls the primary pitch
the other controls the delay time
the binary section adds to the primary pitch
x   x  x  x  x
160 80 40 20 10
the combonation of these three things will determine the pitch heard
this is based off the theremin code by tom igoe
*/
//constants…this will be for switches
const int switchpin1=2;
const int switchpin2=3;
const int switchpin3=4;
const int switchpin4=5;
const int switchpin5=6;
const int switchpin6=7;
int buttonstate=0;//for switch 1 adds 160
int buttonstate1=0;//for switch 2 adds 80
int buttonstate2=0;//for switch 3 adds 40
int buttonstate3=0;//for switch 4 adds 20
int buttonstate4=0;//for switch 5 adds 10
void setup()
{
Serial.begin(9600);
//setup pins to read
pinMode(switchpin1,INPUT);
pinMode(switchpin2,INPUT);
pinMode(switchpin3,INPUT);
pinMode(switchpin4,INPUT);
pinMode(switchpin5,INPUT);
}
void loop()
{
// get a sensor reading:
int sensorReading = analogRead(0);
// map the results from the sensor reading’s range
// to the desired pitch range:
//originally set to 200-900
//0-1023 sounds like telephone
//20 to 20000 hz is the range of human hearing this can be changed though
int pitch1 = map(sensorReading, 0, 1023, 20, 20000);
//these control the delay time the range is from 0 to 100
int multiply=analogRead(1);
int multiplymap=(multiply, 0,1023,0,100);
//integer for the final pitch heard
int finaltone=pitch1;
//read button
buttonstate=digitalRead(switchpin1);
if(buttonstate==HIGH)
{
//add 160 to finaltone
finaltone=finaltone+160;
}
buttonstate1=digitalRead(switchpin2);
if(buttonstate1==HIGH)
{
//add 60
finaltone=finaltone+60;
}
buttonstate2=digitalRead(switchpin3);
if(buttonstate2==HIGH)
{
//add 40
finaltone=finaltone+40;
}
buttonstate3=digitalRead(switchpin4);
if(buttonstate3==HIGH)
{
//adds 20
finaltone=finaltone+20;
}
buttonstate4=digitalRead(switchpin5);
if(buttonstate4==HIGH)
{
//adds 10
finaltone=finaltone+10;
}
//add this button to turn on crazy mode
//you can control the delay time of the whole program
buttonstate5=digitalRead(switchpin6);
if(buttonstate5==HIGH)
{
crazymode=1;
}
if(buttonstate5==LOW)
{
crazymode=0;
}
// change the pitch, 10 ms duration:
//output from pin8, play this tone value, 10 ms duration
tone(8, finaltone, 10);
// delay(90);
//if crazymode is on then you have variable delay switches don’t work so good here though
if(crazymode==1)
{
delay(multiply);
}
/* for debugging
Serial.println(“analogvalue1: “);
Serial.print( sensorReading );
Serial.print(“multiply ” );
Serial.print(multiply );
Serial.print(“finaltone ” );
Serial.print(finaltone );*/
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
in the code you first set up constants for your switches. For example switchpin1=2; means switch 1 is on digital pin 2. Then we set up buttons states for these switches
they are all set to 0 or LOW meaning they are off. Next set up pinModes all the the switches are set up as inputs. In the Loop we are reading the values from the potentiometers and them mapping them to whatever range you want. For the first pot i mapped them to 20-20000hz which is the range of human hearing. The second pot is mapped to a range of 0-100. Then we set the buttonstates to be equal to the readings coming off the pins, if they read HIGH then we do something. Each switch has a numerical value attached to it.
IF the switch is HIGH then we add this value to the pitch.Then we check to see if the last switch is on or off. If it’s on then you are given control over the programs delay time, this will turn the sound on and off depending the on value that is read. Finally we use the tone() function , this is included with arduino 18. We tell it which pin to use for the speaker, what pitch or tone to play, then the duration or how long to play.
I have collected all the schematics and code in a zip file you can download everything here:
here is a photo of the synth in its enclosure:
Also there is video and other software, I was able to use this as a HID ( human interface device) so it can be used with pure data, all necessary software is included and there is a readme file:

Comments are closed.