It depends on your compiler. See if there is a pre-defined function that allows to to send a signal to the speaker.
Otherwise you have to check if your compiler allows you to send a value to a specific port, e.g. inport() outport().
I forgot the exact port numbers but maybe someone else can tell you. If not, reply and I will find it out.
I found some old code snippets and put them together to an example that works with Visual C++ 6.
I am sure there is an easier way but this one works however.
#include <conio.h>
void sound(unsigned);
void nosound(void);
int main(void)
{
sound(440); // play "a"
for(unsigned long l=0;l<1000000;++l); // wait some time
nosound(); // stop beeping
return 0;
}
void sound(unsigned frequency) // freq = Hz
{
const long F = 0x1234dc; // clock frequency
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.