-
C question
I'm writing a program in C to get the computers internal speaker to transmit a morse code message.
I have no problem transmitting a dot, I use the \a command inside of printf, but I can't repersent a dash, (three times the length of a dot). I've tried using \a three times in a row but it doesn't sound right so I was wondering does anybody know how I might achieve this.
Also is there a command to stop a program operating for a length of time (such a sleep command or something) to put the spaces in the message?
Thanks in advance,
Garathjax
-
hello,
#include <time.h>
stop a program operating for a length of time -
sleep( time_t timeout_in_seconds )
bet you didn't see that comin', but i don't like it because it tends to act differently for different computers because it is only as accurate as the system clock.
other choices:
msleep( long timeout_in_miliseconds )
usleep( unsigned long timeout_in_microseconds )
Edit:
for windows C++ heads, it seems to be
Sleep( int timeout_in_seconds )
and you also have to #include <windows.h>. they all return int's
there are functions in the <sound.h> for messing with the built in speaker.
Code:
//must have IBMPC compatible hardware and software
sound_beep( int frequency )
sound_click();
sound_tone( int cycles, int uptime, int dntime )
-
You might try using an ASCII code a'la ...
printf( "\022");
for your long dash. I can't remember what it was that
I needed the same thing for a while back, but using
the ASCII decimal ( or Hex ) code truned out to be
the easiest way to get what I wanted, and it made
iterration a lot easier too.