Arduino String Instrument

7.0K122

Intro: Arduino String Instrument

Sure you can use LDR's, potentiometers and buttons to generate sounds, but what about strings?

When I began thinking about an Arduino string instrument, I realized what I wanted to create was a soft potentiometer.  I found my inspiration from Hannah Perner-Wilson's Fabric Potentiometer http://www.kobakant.at/DIY/?p=543.


String Instrument from mizliz on Vimeo.



STEP 1: Parts

  •      Arduino Microcontroller
  •     3.3Ω resistor (1 per string)
  •     Conductive thread Lame Lifesaver Lamé Lifesaver
  •     Nickel/Copper/Cobalt Fabric Tape http://www.lessemf.com/fabric.html
  •     8Ω speaker (1 per string)
  •     Solderless breadboard
  •     22-AWG hookup wire
  •     30-AWG wire (optional)
  •     Wooden Dowel
  •     Metal nails or small screw eyes
  •     Drill
  •     Saw
  •     Needle
  •     Scissors
  •     Wire Stripper
  •     Pencil or marker
  •     Box

STEP 2: How It Works

Each string is basically a potentiometer that controls the sound of a speaker.

STEP 3: Building the Instrument

1. Cut two pieces of a wooden dowel. Your length is determined by how long you want your bridge to be. The dowels purpose here is to keep the strings away from your GND.

2.Mark where you want to drill holes on your dowels. Remember, you want to keep the strings off your GND. You should drill holes so that when you string the instrument the strings are parallel to each other.

3.Using a glue gun, fix your dowel onto your box.

4. Either drill holes for nails or screws on the outer side of your dowels or  solder 30 AWG wire to eye screws and thread them through the dowels. If you are doing the the eye screws, one side goes to the analog pins, the other goes to power through a 3.3Ω resistor. I used red wires on one side to go to power and yellow wires to go to the analog pins. For the demo version the alligator clips attach to one nail connecting together an analog input and power through a resistor.


STEP 4: Making Connections

1. You'll have to figure out a way to connect the tape to GND on the Arduino. One option is to use alligator clips. Another is to use brads and solder them together on the inside.

2. Using the conductive thread on a needle, attach the conductive thread to the screws or nails. Tightly string the threads across. Weave the thread across at least twice. Use one string to attach all the nails or screws. 

3. Connect one nail or screw to power through the 3.3Ω resistor .

4. Connect one nail or screw to an analog pin.

4. Attach at least one 8Ω speaker through a 100Ω resistor to a digital pin.

5. Create a pick or bow. It can be anything as long as it is conductive.

STEP 5: The Tone Library

The Tone Library can be used to produce square-waves of the specified frequency on any Arduino pin. You can set the duration of the sound or use the method stop() to stop the sound.

To play a tone, connect a pin to a piezo buzzer or a speaker.

For this demo, I used a 8Ω speaker connected to pin 7 through a 100Ω resistor.


To use the library, you need to instantiate an instance of Tone:

	#include <Tone.h>

Tone notePlayer;

void setup(void){
     //the number reflects the speaker pin
     notePlayer.begin(7);
}
void loop(){
     //To play a note:
     notePlayer.play(NOTE_B3);
}

These are the methods that you can use with this Library:

begin() - prepares a pin for playing a tone.
isPlaying() - returns true if tone is playing, false if not.
play() - play a tone.
stop() - stop playing a tone.

This is a list of constant values of frequencies for notes:
Constant NameFrequency (Hz) NOTE_B2 123 NOTE_C3 131 NOTE_CS3 139 NOTE_D3 147 NOTE_DS3 156 NOTE_E3 165 NOTE_F3 175 NOTE_FS3 185 NOTE_G3 196 NOTE_GS3 208 NOTE_A3 220 NOTE_AS3 233 NOTE_B3 247 NOTE_C4 262 NOTE_CS4 277 NOTE_D4 294 NOTE_DS4 311 NOTE_E4 330 NOTE_F4 349 NOTE_FS4 370 NOTE_G4 392 NOTE_GS4 415 NOTE_A4 440 NOTE_AS4 466 NOTE_B4 494 NOTE_C5 523 NOTE_CS5 554 NOTE_D5 587 NOTE_DS5 622 NOTE_E5 659 NOTE_F5 698 NOTE_FS5 740 NOTE_G5 784 NOTE_GS5 831 NOTE_A5 880 NOTE_AS5 932 NOTE_B5 988 NOTE_C6 1047 NOTE_CS6 1109 NOTE_D6 1175 NOTE_DS6 1245 NOTE_E6 1319 NOTE_F6 1397 NOTE_FS6 1480 NOTE_G6 1568 NOTE_GS6 1661 NOTE_A6 1760 NOTE_AS6 1865 NOTE_B6 1976 NOTE_C7 2093 NOTE_CS7 2217 NOTE_D7 2349 NOTE_DS7 2489 NOTE_E7 2637 NOTE_F7 2794 NOTE_FS7 2960 NOTE_G7 3136 NOTE_GS7 3322 NOTE_A7 3520 NOTE_AS7 3729 NOTE_B7 3951 NOTE_C8 4186 NOTE_CS8 4435 NOTE_D8 4699 NOTE_DS8 4978

More information can be found here:ToneLibraryDocumentation

STEP 6: Putting It Altogether

Here is code for a two speaker instrument:
	#include <Tone.h>


int potValue;
int potValue2;

Tone speaker[2];
int notes[] = { 
  NOTE_A3,
  NOTE_B3,
  NOTE_C4,
  NOTE_D4,
  NOTE_E4,
  NOTE_F4,
  NOTE_G4,
  NOTE_A4,
  NOTE_B4,
  NOTE_C5,
  NOTE_D5,
  NOTE_E5,
  NOTE_F5,
  NOTE_G5,
  NOTE_A5,
  NOTE_B5,
  NOTE_C6};
void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
  speaker[0].begin(7);
  speaker[1].begin(8);
}
void loop() {

  potValue = analogRead(A0);   // read the pot value
 
 Serial.println(potValue);
 if (potValue<100){
    speaker[0].play(notes[0]);
     speaker[1].play(notes[12]);
  } 
  else if (potValue<200){
    speaker[0].play(notes[1]);
    speaker[1].play(notes[11]);
  }
  else if (potValue<250){
    speaker[0].play(notes[2]);
    speaker[1].play(notes[10]);
  }
  else if (potValue<320){
    speaker[0].play(notes[3]);
    speaker[1].play(notes[9]);
  }
  else if (potValue<400){
    speaker[0].play(notes[4]);
    speaker[1].play(notes[8]);
  }
  else if (potValue<450){
    speaker[0].play(notes[5]);
    speaker[1].play(notes[7]);
  }
  else if (potValue<500){
    speaker[0].play(notes[6]);
    speaker[1].play(notes[4]);
  }
  else if (potValue<550){
    speaker[0].play(notes[7]);
    speaker[1].play(notes[3]);
  }
  else if (potValue<700){
    speaker[0].play(notes[8]);
    speaker[1].play(notes[2]);
  }
  else if (potValue<900){
    speaker[0].play(notes[9]);
    speaker[1].play(notes[1]);
  }
  else{
    speaker[0].stop();
    speaker[1].stop();
  }

2 Comments

it's cool man

Any chance of a recording?