I can successfully transmit tones to an AM radio nearby with this code:
void tone(int freq, int duration){
if(freq == 0){delay(duration); return;}
unsigned loops = (800000 / freq);
long wait = (1000000 / freq);
long v = (duration / ((wait*2)/1000));
for(long k = 0;k < v;k++){
for(unsigned i = 0;i < loops;i++){
PORTD ^= 0x8;
}
delayMicroseconds(wait);
}
}
void setup(){
tone(440, 500); //Play A4 for 500ms
}
void loop(){}
The circuit is a 1K resistor from pin 3 to an antenna.
It works by actually turning the pin on and off over 800000 times per second.
Received frequency is between 880 and 890 khz.