Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Vibrating motor musical instruent help on: November 15, 2012, 03:17:03 pm
I'm new to using arduino

I'm designing and building a musical instrument for a university project . one aspect involves using a vibrating motor attached to surface to generate audible frequencies. I've never used a vibrating motor but as far as I understand the revolution speed is controllable(would control frequency) and they have a constant amplitude?

I really want to have dynamic control over the volume of the sound produced. Any suggestions for a neat way of achieving this? The only solution I can think of is using a moving part to physically dampen the vibrating surface, but this would also dramatically effect timbre (I think). It also generally seems like it would be quite difficult and I have a tight time schedule. Help me please!
2  Using Arduino / Project Guidance / wooden box size/proportions for best acoustics? on: November 15, 2012, 12:17:19 pm
Anyone know much about acoustics?

I'm basically building a kind of musical instrument that's a wooden box (thinking birch plywood? - I don't want to spend too much money) with some solenoids and vibrating motors inside that generate noise on various materials' surfaces. The kind of size i picture the box is 30cm x 30cm x 45 cm (1.5ish cm thick)

I'm not particularly knowledgeable about acoustics, would there be a particular optimums size/proportions for the best acoustics?  and is there a better (cheapish) material i could use?
3  Using Arduino / Motors, Mechanics, and Power / Solenoids? on: November 15, 2012, 08:51:09 am
I've never worked with solenoids. I want to buy around 3-5 for a mini project similar to this: http://www.youtube.com/watch?feature=player_embedded&v=g_hiz-Kx0kM (except inside a wooden box instrument)

any recommendations for the cheapest i could buy that will do the job suitably? I don't want to spend more than I have to (I'm a student ) and i don't particular get the specs for them.

thanks.
4  Using Arduino / Programming Questions / Re: curious problem with arrays in simple play/record device on: October 24, 2012, 11:03:21 am
ahhh ok thanks : )
5  Using Arduino / Programming Questions / curious problem with arrays in simple play/record device on: October 24, 2012, 10:42:50 am
Hi

I made a simple record and playback device for a lab task at university. You play sound through a piezo element, controlling the frequency with a potentiometer. Every time you play something the values are recorded in an array and can then be played back by pressing a button. A weird thing I found was that if the array size is over around 400 (it’s a float array), then the whole thing just doesn’t work. There’s no error message or anything, just nothing happens. It can’t be because there’s not enough space on the arduino board – a way bigger array should still easily fit, plus the IDE would tell me if this was the case anyway.

If you delete the bit of code that fills the array with the current freq values (the bit that records), then the whole thing works again (although obviously it won’t record anymore, it’ll just play sound). So I’m pretty sure that’s the bit it doesn’t like. With an array size of around 400 or less though, it all works perfectly. It feels like it’s a matter of processing power, and the board can’t handle it. I don’t understand how that could be the case either though, as for each iteration essentially the same process is happening regardless of the array size -> a value is stored into an array and then the index is increased by one. It’s not even a massive problem because 400 is easily big enough for the sake of the project. I’m more curious as to why this happens. Does anyone have any Idea?
Here’s the entire code if it helps:
(NOTE: 400 isn’t the exact value it won’t work after. I didn’t bother finding that out, but it definitely won’t work with values much bigger like 500)

int piezoPin = 8; // pin for piezo element.
int potenPin = 0; // pin for potentiometer.
int playPin = 12; // pin for playback button.
int recPin = 13; // pin for record button.
int recSwitch = 0; // value for record button.
int playSwitch = 0; // value for playback button.
int recPos = 0; // position in array for recording.
boolean erase = false;
float rec[400]; // array holds frequency values to play back.
int sampleRate = 50;


void setup(){
  //Serial.begin(9600);
  pinMode(piezoPin,OUTPUT);
  pinMode(potenPin,INPUT);
  pinMode(playPin,INPUT);
  pinMode(recPin,INPUT);
 
 
}

void loop(){
  int potenVal = analogRead(potenPin);
  // map the potentiometer values to desired freq values.
  float freq = map(potenVal,0,1023,100,1000);
  // read button values.
  recSwitch = digitalRead(recPin);
  playSwitch = digitalRead(playPin);
  /* when record button is pressed:
  (play button has to not be pressed so you cant try and
   record and play back at the same time) */
  if(recSwitch ==LOW && playSwitch == HIGH){
    // playback live
    tone(piezoPin,freq,100); //
    if (recPos < 400){
      /* record current value of frecuency into array while recPos
      is smaller than array size, increasing recPos by 1 each sample
      */
      rec[recPos] = freq;  // ----- THIS IS THE BIT IT DOESN’T LIKE WITH BIG ARRAYS
      recPos++;
      // delay by sample rate value
      delay(sampleRate);
      //Serial.println(recPos);
      erase = true;
    }
  }
  // when record is button released:
  else{
    /* erase all possible previously recorded data passed what has
    already been rewritten*/
    if(erase == true){
      for(int i=recPos;i<400;i++){
        rec=0;
      }
    }
    /* erase boolean set to true while recording and to false
    after data is erased so it only erases once and doesn’t
    continuously repeat and erase all the data */
    erase = false;
    // set rec pos back to zero
    recPos = 0;
  }
 
  // when play back button pressed:
  if(playSwitch == LOW && recSwitch == HIGH){
    // go through rec array and play it back
    for(int i=0;i<400;i++){
      /* stop playback if end of recording is before the
      record limit */
      if(rec == 0){
        break;
      }
      tone(piezoPin,rec,100);
      delay(sampleRate);
    }
    /* delay so button works like switch, giving enough time to
     lift finger before calling functions again*/
    delay(1000);
  }
}
Pages: [1]