c_cpp 430摩尔斯电码生成器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 430摩尔斯电码生成器相关的知识,希望对你有一定的参考价值。

/*
 * Morse code simuator for the MSP430 
 * 
 * 
 * 
 */

#define LED RED_LED

int dt = 100; // the "time unit" 

// A dirty way 
int a[] = {2,1,3};
int b[] = {4,3,1,1,1};
int c[]= {4,3,1,3,1};
int d[] = {3,3,1,1};
int e[] = {1,1};
int f[] = {4,1,1,3,1};
int g[] = {3,3,3,1};
int h[] = {4,1,1,1,1};
int i[] = {2,1,1};
int j[] = {4,1,3,3,3};
int k[] = {3,3,1,3};
int l[] = {4,1,3,1,1};
int m[] = {2,3,3};
int n[] = {2,3,1};
int o[] = {3,3,3,3};
int p[] = {4,1,3,3,1};
int q[] = {4,3,3,1,3};
int r[] = {3,1,3,1};
int s[] = {3,1,1,1};
int t[] = {1,3};
int u[] = {3,1,1,3}; 
int v[] = {4,1,1,1,3};
int w[] = {3,1,3,3};
int x[] = {4,3,1,1,3};
int y[] = {4,3,1,3,3};
int z[] = {4,3,3,1,1};
int sp[]= {3,0,0,0};
 
void setup() {                
  pinMode(LED, OUTPUT);     
  Serial.begin(9600);
}

void loop() {

  
  toMorse(i);
  delay(4*dt);
  
  toMorse(l);
  toMorse(o);
  toMorse(v);
  toMorse(e);
  delay(4*dt);
  
  toMorse(y);
  toMorse(o);
  toMorse(u);
  delay(11*dt);

}

void toMorse(int letter[]){
  int len = letter[0];
  for(int ind = 1; ind < len + 1; ind = ind+1){
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(dt*letter[ind]);               // wait for a second
  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
  delay(dt);               // wait for a second
  }
  
  Serial.println(" ");
  delay(3*dt);

}

以上是关于c_cpp 430摩尔斯电码生成器的主要内容,如果未能解决你的问题,请参考以下文章

CTF 基础 1(摩尔斯电码)

摩尔斯电码

i love you用摩尔斯电码怎么写?

摩尔斯电码音频解码器(Android)[关闭]

摩尔斯电码解码

摩尔斯电码解码