FRUIT PIANO

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.

Gdiafano

Might I suggest you read this for future reference

Bob.

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.

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.