I like programming the Texas Instrument MSP430 and Stellaris micro-processors. I have several of their kits, one of which is a Stellaris EK-LM4F120XL. Obviously, you have to make sure you set your IDE to your chip type. But I believe this will run OK on most MSP430 and Stellaris boards. I imagine it would be easy to adapt to an Arduino or Raspberry Pi also.
I'm building a small 10mW transmitter with just the oscillator, first buffer, and the keying circuit as shown in "A First Transmitter", Experimental Methods in RF Design (EMRFD). That circuit keys by grounding the base of a PNP transistor. So I developed this to blink an LED, and will later adapt it to also ground an I/O pin.
Here's the code:
/*
Beacon by John Burgoon KC9TUI - January 2016
Blink an LED in Morse code using my callsign
For the EMRFD 1st Transmitter, alternate the emitter pin of the keying transistor to ground instead of (or, perhaps in addition to) flashing an LED.
Hardware Required;
* LaunchPad with an LED
This software is free for public use. Please be certain to change the callsign to your own.
*/
// most launchpads have a red LED
#define LED RED_LED
#define DOTLENGTH 110
#define EL_SPACE DOTLENGTH*1
#define CHAR_SPACE DOTLENGTH*3
#define WORD_SPACE DOTLENGTH*7
String CALL_MSG;
// the setup routine runs once when you press reset;
void setup() {
// initialize the digital pin as an output.
pinMode(LED, OUTPUT);
CALL_MSG = String("BEACON"); // TWO_BY_TWO or BEACON, all else sends "73"
}
// the loop routine runs over and over again forever;
void loop() {
if (CALL_MSG == "TWO_BY_TWO") {
MORSE_C();MORSE_Q();delay(WORD_SPACE);
MORSE_C();MORSE_Q();delay(WORD_SPACE);
MORSE_D();MORSE_E();delay(WORD_SPACE);
MORSE_K();MORSE_C();MORSE_9();MORSE_T();MORSE_U();MORSE_I();delay(WORD_SPACE);
MORSE_K();MORSE_C();MORSE_9();MORSE_T();MORSE_U();MORSE_I();delay(WORD_SPACE);
MORSE_K();delay(WORD_SPACE);
} else if (CALL_MSG == "BEACON") {
MORSE_K();MORSE_C();MORSE_9();MORSE_T();MORSE_U();MORSE_I();delay(WORD_SPACE);TONE();delay(WORD_SPACE);
} else {
MORSE_73();delay(WORD_SPACE);
}
}
void DASH() {
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(CHAR_SPACE); // wait for a dash-length of time
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(EL_SPACE); // wait for a dit-length of time
}
void DIT() {
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(EL_SPACE); // wait for a dit-length of time
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(EL_SPACE); // wait for a dit-length of time
}
void TONE() {
digitalWrite(LED, HIGH);
delay(WORD_SPACE*2);
digitalWrite(LED, LOW);
delay(EL_SPACE);
}
void MORSE_K() {
DASH(); DIT(); DASH();delay(CHAR_SPACE);
}
void MORSE_C() {
DASH();DIT();DASH();DIT();delay(CHAR_SPACE);
}
void MORSE_9() {
DASH();DASH();DASH();DASH();DIT();delay(CHAR_SPACE);
}
void MORSE_T() {
DASH();delay(CHAR_SPACE);
}
void MORSE_U() {
DIT();DIT();DASH();delay(CHAR_SPACE);
}
void MORSE_I() {
DIT();DIT();delay(CHAR_SPACE);
}
void MORSE_Q() {
DASH();DASH();DIT();DASH();delay(CHAR_SPACE);
}
void MORSE_D() {
DASH();DIT();DIT();delay(CHAR_SPACE);
}
void MORSE_E() {
DIT();delay(CHAR_SPACE);
}
void MORSE_73() {
DASH();DASH();DIT();DIT();DIT();delay(EL_SPACE);DIT();DIT();DIT();DASH();DASH();delay(WORD_SPACE);
}
No comments:
Post a Comment