Go Down

Topic: FRUIT PIANO (Read 89 times) previous topic - next topic

Gdiafano

Hello everbody!

I am doing a Fruit Piano with Arduino but I have a problem with the code. We don't want to use an speaker because we want to use the computer sound but I don't know how to write the code. I have his:

int pos = 0;
int buzz=11;

void setup()
{
  pinMode(buzz, OUTPUT);
  pinMode(A5, INPUT);
}

void loop()
{
  if (digitalRead(A5) == LOW) {
    tone(buzz, 440, 100); // play tone 57 (A4 = 440 Hz)
  }
  delay(10); // Delay a little bit to improve simulation performance
}


But this code is made for buzzer use. I hope somebody could help us.

ballscrewbob

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Delta_G

Hello everbody!

I am doing a Fruit Piano with Arduino but I have a problem with the code. We don't want to use an speaker because we want to use the computer sound but I don't know how to write the code. I have his:

int pos = 0;
int buzz=11;

void setup()
{
  pinMode(buzz, OUTPUT);
  pinMode(A5, INPUT);
}

void loop()
{
  if (digitalRead(A5) == LOW) {
    tone(buzz, 440, 100); // play tone 57 (A4 = 440 Hz)
  }
  delay(10); // Delay a little bit to improve simulation performance
}


But this code is made for buzzer use. I hope somebody could help us.
You have two options.  If you're using a makey makey or a Leonardo or some other breed of Arduino that can pretend to be a keyboard then you can write a program to run on the PC that reads letters from the keyboard and plays notes on the speaker.  But you write that on the PC and not the Arduino.

The other option is MIDI. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Go Up