YaK:: Sample CW beacon keyer on ATtiny45 [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
[mega_changes]
[photos]

Sample CW beacon keyer on ATtiny45




#define PIN 0  /* Pin 5 on the ATtiny45 or 85.  Built-in LED on programmer. */
#define WPM 6
#define DIT_MILLIS ((int)(1200/(WPM))) /* 100 milliseconds is 12 WPm */
#define PAUSE_MILLIS 3000 /* before repeating */
#define V  "...- "
#define D  "-.. "
#define W  ".-- "
#define _6 "-.... "
#define R  ".-. "
#define E  ". "
#define K  "-.- "
#define __ " "
const char Message[] = V V V __ D E __ W _6 R E K ;

void TurnOnFor(int num_dits) { digitalWrite(PIN, HIGH); delay(num_dits*DIT_MILLIS); }
void TurnOffFor(int num_dits) { digitalWrite(PIN, LOW); delay(num_dits*DIT_MILLIS); }
void Fist(int ch) {
  switch (ch) {
    case '.': TurnOnFor(1); TurnOffFor(1); break;  // dit
    case '-': TurnOnFor(3); TurnOffFor(1); break;  // dah
    default: TurnOffFor(2); break;  // end of letter
  }
}
void setup() {
  pinMode(PIN, OUTPUT); // initialize PIN as a digital output.
}
void loop() {
  int ch, i = 0;
  while (ch = Message[i++]) {
    Fist(ch);
  }
  delay(PAUSE_MILLIS);
}




(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2018-09-24)       [Login]
(No back references.)