MDRAID superblock generator
[mirrors/Programs.git] / arduino / AM_Broadcast_Modulator / AM_Broadcast_Modulator.pde
1 /*Copy the code below and up load it to the I/O Board
2 then put some kind of Antenna into PIN 8...PIN 8!!!!
3 Then tune to AM 1337kHz.
4 Optional:LED in pin 13 to see what is broadcasting,
5 also a protoshield to add multiple antenna's.
6 Lol that code will do morse code saying "I like ice cream";
7 *********THE CODE****************************************************
8 */
9 //start of code
10 //WWW.JONNYBLANCH.WEBS.COM
11 long millisAtStart = 0;
12 long millisAtEnd = 0;
13
14 const long period_broadcast = 8; //period of shortest broadcast (256 port changes)
15
16 #define LENGTH_DIT 64
17 //number of period_broadcasts in one 'dit',
18 //all other lengths are scaled from this
19 //Broadcasts on 1337 kHz
20
21 const int length_dit = LENGTH_DIT; //number of periods for dit
22 const int pause_dit = LENGTH_DIT; //pause after dit
23 const int length_dah = 3 * LENGTH_DIT; //number of persots for dah
24 const int pause_dah = LENGTH_DIT; //pause after dah
25 const int length_pause = 7 * LENGTH_DIT; //pause between words
26
27 void dit(void);
28 void dah(void);
29 void pause(void);
30 void broadcast(int N_cycles);
31 void dontbroadcast(int N_cycles);
32
33 // ### INC ### Increment Register (reg = reg + 1)
34 #define ASM_INC(reg) asm volatile ("inc %0" : "=r" (reg) : "0" (reg))
35
36 void setup() {
37
38 Serial.begin(9600);
39 DDRB = 0xFF; //Port B all outputs
40 //Do one dit to determine approximate frequency
41 millisAtStart = millis();
42 dit();
43 millisAtEnd = millis();
44 Serial.print(millisAtEnd - millisAtStart);
45 Serial.print(" ");
46 Serial.print((length_dit + pause_dit) * period_broadcast * 256 /
47 (millisAtEnd - millisAtStart) / 2);
48 Serial.print("kHz ");
49 Serial.println();
50 }
51
52 void loop() {
53 dit();
54 dit();
55 delay(500);
56 dit();
57 dah();
58 dit();
59 dit();
60 delay(250);
61 dit();
62 dit();
63 delay(250);
64 dah();
65 dit();
66 dah();
67 delay(250);
68 dit();
69 delay(500);
70 dit();
71 dit();
72 delay(250);
73 dah();
74 dit();
75 dah();
76 dit();
77 delay(250);
78 dit();
79 delay(500);
80 dah();
81 dit();
82 dah();
83 dit();
84 delay(250);
85 dit();
86 dah();
87 dit();
88 delay(250);
89 dit();
90 delay(250);
91 dit();
92 dah();
93 delay(250);
94 dah();
95 dah();
96 delay(2000);
97
98 }
99
100 void dit(void) {
101 for (int i = 0; i < length_dit; i++)
102 {
103
104 broadcast(period_broadcast);
105
106 }
107
108 for (int i = 0; i < pause_dit; i++)
109 {
110
111 dontbroadcast(period_broadcast);
112
113 }
114
115 }
116
117 void dah(void) {
118 for (int i = 0; i < length_dah; i++)
119 {
120
121 broadcast(period_broadcast);
122
123 }
124
125 for (int i = 0; i < pause_dah; i++)
126 {
127
128 dontbroadcast(period_broadcast);
129
130 }
131
132 }
133
134 void pause(void) {
135 for (int i = 0; i < length_pause; i++)
136 {
137
138 dontbroadcast(period_broadcast);
139
140 }
141
142 }
143
144 void broadcast(int N_cycles) {
145 unsigned int portvalue;
146 for (int i = 0; i < N_cycles; i++)
147 {
148
149 portvalue = 0;
150
151 do {
152 PORTB = portvalue;
153 ASM_INC(portvalue);
154 }
155 while (portvalue < 255);
156 }
157 }
158
159 void dontbroadcast(int N_cycles) {
160 unsigned int portvalue;
161 PORTB = 0x00;
162 for (int i = 0; i < N_cycles; i++)
163 {
164
165 portvalue = 0;
166
167 do {
168 ASM_INC(portvalue);
169 //add some assembly No OPerations to keep timing the same
170 asm volatile ("NOP");
171 }
172 while (portvalue < 255);
173 }
174 }
175
176 //end of code
This page took 0.408326 seconds and 4 git commands to generate.