Hia, I've found this old thread where someone under the nick Anymouse mentions having used the attiny as a morse code beacon in the AM band:
I will very much appreciate to know how complex is to "port" the code in that thread (below) to be used on ATTINY's? I don't think is as simple as changing pin numbers unfortunately.
/a
// ### INC ### Increment Register (reg = reg + 1)
#define ASM_INC(reg) asm volatile ("inc %0" : "=r" (reg) : "0" (reg))
void setup()
{
Serial.begin(9600);
DDRB=0xFF; //Port B all outputs
//Do one dit to determine approximate frequency
millisAtStart=millis();
dit();
millisAtEnd=millis();
Serial.print(millisAtEnd-millisAtStart);
Serial.print(" ");
Serial.print((length_dit+pause_dit)*period_broadcast*256/(millisAtEnd-millisAtStart)/2);
Serial.print("kHz ");
Serial.println();
}
void loop()
{
dah();
dit();
dah();
dah();
pause();
dah();
dit();
dah();
dah();
pause();
dah();
dah();
dit();
dit();
pause();
pause();
}
void dit(void)
{
for(int i=0;i<length_dit;i++)
{
broadcast(period_broadcast);
}
for(int i=0;i<pause_dit;i++)
{
dontbroadcast(period_broadcast);
}
}
void dah(void)
{
for(int i=0;i<length_dah;i++)
{
broadcast(period_broadcast);
}
for(int i=0;i<pause_dah;i++)
{
dontbroadcast(period_broadcast);
}
}
void pause(void)
{
for(int i=0;i<length_pause;i++)
{
dontbroadcast(period_broadcast);
}
}
void broadcast(int N_cycles)
{
unsigned int portvalue;
for (int i=0;i<N_cycles;i++)
{
portvalue=0;
do
{
PORTB=portvalue;
ASM_INC(portvalue);
}
while(portvalue<255);
}
}
void dontbroadcast(int N_cycles)
{
unsigned int portvalue;
PORTB=0x00;
for (int i=0;i<N_cycles;i++)
{
portvalue=0;
do
{
ASM_INC(portvalue);
//add some assembly No OPerations to keep timing the same
asm volatile ("NOP");
}
while(portvalue<255);
}
}