Skip to content

Instantly share code, notes, and snippets.

@stilldavid
Created June 10, 2010 16:54
Show Gist options
  • Save stilldavid/433288 to your computer and use it in GitHub Desktop.
Save stilldavid/433288 to your computer and use it in GitHub Desktop.
// RADIO
#define RADIO_SPACE 10
#define RADIO_MARK 11
#define ASCII_BIT 8
void rtty_txstring (char * string) {
char c;
c = *string++;
while ( c != '\0') {
rtty_txbyte (c);
c = *string++;
}
}
void rtty_txbyte (char c) {
int i;
rtty_txbit (0); // Start bit
// Send bits for for char LSB first
for (i=0; i<ASCII_BIT; i++) {
if (c & 1)
rtty_txbit(1);
else
rtty_txbit(0);
c = c >> 1;
}
rtty_txbit (1); // Stop bit
rtty_txbit (1); // Stop bit 2
}
void rtty_txbit (int bit) {
if (bit) {
digitalWrite(RADIO_SPACE, LOW);
digitalWrite(RADIO_MARK, HIGH);
} else {
digitalWrite(RADIO_SPACE, HIGH);
digitalWrite(RADIO_MARK, LOW);
}
// This works out to a baud rate of 50 bps. Somehow.
delay(19);
delayMicroseconds(250);
}
void setup() {
pinMode(RADIO_SPACE, OUTPUT);
pinMode(RADIO_MARK, OUTPUT);
}
void loop() {
rtty_txstring("Hello World!");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment