this code generates a binary signal represented as 10101 every 5 seconds. I now need a way to record this signal and save it as an audio file (.wav, .mp3, etc), how would I go about doing that?
MP3? You cannot save something in MP3 which your ears cannot hear. The reason MP3 compresses like it does is throwing away everything that can't be heard by the human ear. Your rectangle output has 5 Hz which is outside the frequency range a human is able to detect with it's audio sensors.
Spoken easily: this is not an audio signal. You can produce a WAV file containing that information with a little programming on the PC, you don't have to "record" it. What's your intention? What do you wanna achieve?
Oh neat. However, .wav would work as well; it would probably be better. How would I go about converting the arduino file into a .wav file? I basically want to create a library of binary signals (stored as .wav) which I can run(on a laptop, cell phone, etc) in order to command an arduino driven platform I have designed. Basically one way communication via On-Off shift keying
Wikipedia has plenty of information about the WAV format (WAV - Wikipedia).
How would I go about converting the arduino file into a .wav file
You wanna convert an Arduino sketch to a WAV file? An arduino cannot make music (at least I won't call that noise so) and a WAV file cannot program an arduino, so there's no conversion possible. Maybe I don't understand what you wanna do.
You're telling that you wanna command an Arduino by playing sounds on the computer? I guess you have a much too simplified view to this area. You won't be successful by playing a 5Hz sound on the computer and attach a microphone to the Arduino to "act" on that command sequence.
How do I produce a .wav file containing the information ? My plan is to create a .wav file containing a binary signal/on-off shift keying. Then if I wanted to command my arduino driven platform, I would connect an audio plug from my laptop (or smartphone etc) to a pin on the arduino. That pin then analzyes the signal being played, from the .wav file, using analog read and an algorithm to convert the values into a sequence of eight 1's and 0's. It then recognizes each sequence of 1's and 0's and executes the appropriate command. My issue is, I don't have or know how to generate the .wav files. Instead, for debugging purposes, I have been generating the same kind of binary signal (that would be in the .wav file) using an arduino uno with a pin that changes states at specific intervals coupled with delays.
My issue is, I don't have or know how to generate the .wav files.
Well read the link on the wav file format. Basically you just need to add a header to your data.
However your problems do not end there. Encoding data onto an audio sub carrier is not done the way you are going about it. Amplitude modulation is very error prone, you are better off with phase modulation. Look up how old school slow modems modulated data.