How to play sound

As i read Reserved words.pdf of Robotc, it says this code “Playtone(220, 500)” can play sound when external piezoelectric speaker is connected to motor port1. But my robot can’t paly any sound when i do this.

Can anyone help me in programming to make robot play sound?

Can you post the code you are using?

I have successfully used this routine:

 
void beepbeep() {
  PlayTone(800, 10);
  wait10Msec(20);
  PlayTone(800, 10);
  wait10Msec(20);
}

with a piezzoelectric speaker I pulled off a modem card and plugged into the first motor port under robotc.

Are you setting the motor port for audio output? You need to go to “Robot -> Motors and Sensors Setup” and set port1’s type to “Audio Speaker”.

See this page for info.

Cheers,

  • Dean
1 Like

Maybe my speaker is not piezolelectric speaker?
By the way, what does piezoelectric speaker look like? Any external features different from normal speakers?

Pizo Speaker from Science Plus (an interesting supply of stuff)

Roboddsey sells this device

Radio Shack speaker

1 Like

Any difference in style of sound between piezo buzzer and piezo speaker?

Well, a piezo buzzer just needs DC power to operate. They generally produce one single tone when you apply power. There are fancier ones that can produce other sound effects, but they tend to be on when power is applied and off when it isn’t.

A piezo speaker is like a regular speaker in that you feed it an AC signal that it converts into sound. Higher frequency signals will produce higher pitched notes. Higher amplitude signals will produce louder notes.

I believe the RobotC libraries are expecting a piezo speaker rather than a piezo buzzer to be attached. I doubt a buzzer will work at all, or at least not well, but I haven’t personally tried it.

Cheers,

  • Dean

Does it work with piezo tweeter?

I suspect you’d get some sound, though I don’t know if it would be very loud. You should wire it between the outer two contacts on the port (white and black if you are using an extension cable).

  • Dean