You are on page 1of 6

Build Your Own Radio BeaconsEMC Compliant Single-Chip Resolver... http://www.electroschematics.

com/12634/build-your-own-radio-beacons/

1 de 6 24/02/2017 07:31 p. m.
Build Your Own Radio BeaconsEMC Compliant Single-Chip Resolver... http://www.electroschematics.com/12634/build-your-own-radio-beacons/

1. /*
2. An Arduino Morse Beacon
3. Adaptation of a work by Mark VandeWettering
4. Prepared for www.electroschematics.com
5. Authored & Tested by T.K.Hareendran
6. */
7.
8.
9. struct t_mtab { char c, pat; } ;
10.
11. struct t_mtab morsetab[ ] = {
12. {'.', 106},
13. {',', 115},
14. {'?', 76},
15. {'/', 41},
16. {'A', 6},
17. {'B', 17},
18. {'C', 21},
19. {'D', 9},
20. {'E', 2},
21. {'F', 20},
22. {'G', 11},
23. {'H', 16},
24. {'I', 4},
25. {'J', 30},
26. {'K', 13},
27. {'L', 18},
28. {'M', 7},
29. {'N', 5},
30. {'O', 15},
31. {'P', 22},
32. {'Q', 27},
33. {'R', 10},
34. {'S', 8},
35. {'T', 3},
36. {'U', 12},
37. {'V', 24},
38. {'W', 14},
39. {'X', 25},
40. {'Y', 29},
41. {'Z', 19},
42. {'1', 62},
43. {'2', 60},
44. {'3', 56},
45. {'4', 48},
46. {'5', 32},
47. {'6', 33},
48. {'7', 35},
49. {'8', 39},
50. {'9', 47},
51. {'0', 63}
52. } ;
53.
54. #define N_MORSE (sizeof(morsetab)/sizeof(morsetab[0]))
55.
56. #define SPEED (12)
57. #define DOTLEN (1200/SPEED)
58. #define DASHLEN (3*(1200/SPEED))
59.
60. int SIGpin = 13 ;
61.
62. void
63. dash()
64. {
65. digitalWrite(SIGpin, HIGH) ;
66. delay(DASHLEN);
67. digitalWrite(SIGpin, LOW) ;
68. delay(DOTLEN) ;
69. }
70.
71. void
72. dit()
73. {
74. digitalWrite(SIGpin, HIGH) ;
75. delay(DOTLEN);
76. digitalWrite(SIGpin, LOW) ;
77. delay(DOTLEN);
78. }
79.
80. void
81. send(char c)
82. {
83. int i ;
84. if (c == ' ') {
85. Serial.print(c) ;
86. delay(7*DOTLEN) ;
87. return ;
88. }
89. for (i=0; i<N_MORSE; i++) {
90. if (morsetab[i].c == c) {
91. unsigned char p = morsetab[i].pat ;
92. Serial.print(morsetab[i].c) ;
93.
94. while (p != 1) {
95. if (p & 1)
96. dash() ;
97. else
98. dit() ;
99. p = p / 2 ;
100. }
101. delay(2*DOTLEN) ;
102. return ;
103. }
104. }
105. /* if we drop off the end, then we send a space */
106. Serial.print("?") ;
107. }
108.
109. void
110. sendmsg(char *str)
111. {
112. while (*str)
113. send(*str++) ;
114. Serial.println("");
115. }
116.
117. void setup() {
118. pinMode(SIGpin, OUTPUT) ; // Signal Output Pin
119. Serial.begin(9600) ;
120. Serial.println("An Arduino Morse Beacon") ;
121. Serial.println("www.electroschematics.com") ;
122. Serial.println("") ;
123. }
124.
125. void loop() {
126. sendmsg("ESCOM BEACON") ; // Custom Message
127. delay(3000) ;
128. }

2 de 6 24/02/2017 07:31 p. m.
Build Your Own Radio BeaconsEMC Compliant Single-Chip Resolver... http://www.electroschematics.com/12634/build-your-own-radio-beacons/

3 de 6 24/02/2017 07:31 p. m.
Build Your Own Radio BeaconsEMC Compliant Single-Chip Resolver... http://www.electroschematics.com/12634/build-your-own-radio-beacons/

4 de 6 24/02/2017 07:31 p. m.
Build Your Own Radio BeaconsEMC Compliant Single-Chip Resolver... http://www.electroschematics.com/12634/build-your-own-radio-beacons/

5 de 6 24/02/2017 07:31 p. m.
Build Your Own Radio BeaconsEMC Compliant Single-Chip Resolver... http://www.electroschematics.com/12634/build-your-own-radio-beacons/

6 de 6 24/02/2017 07:31 p. m.

You might also like