Browse Source

Txx.uo for the web

master
E.zn 5 months ago
parent
commit
146d83bf1c

BIN
INPUT_OUTPUT/Txx.uo/INPUT_OUTPUT.gif View File


BIN
INPUT_OUTPUT/Txx.uo/LiquidCrystal_I2C.zip View File


BIN
INPUT_OUTPUT/Txx.uo/MFRC522.zip View File


+ 228
- 0
INPUT_OUTPUT/Txx.uo/Txx.uo.ino View File

@@ -0,0 +1,228 @@
1
+
2
+#include <SPI.h>
3
+#include <MFRC522.h>
4
+
5
+#define SS_PIN 10
6
+#define RST_PIN 9
7
+#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
8
+MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
9
+
10
+#include <LiquidCrystal_I2C.h>
11
+//LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE);  // Set the LCD I2C address
12
+LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
13
+
14
+const int RFIDled = 6;
15
+const int RFIDSound = 5;
16
+const int RFIDbin = 3;
17
+const int signalIN = A0;
18
+const int TextKnob = A1;
19
+const int textSound = A2;
20
+long randNumber;
21
+
22
+
23
+
24
+void setup()
25
+{
26
+  Serial.begin(9600); // Initiate a serial communication
27
+  SPI.begin(); // Initiate  SPI bus
28
+  lcd.begin(16, 2); // initialize the lcd
29
+  mfrc522.PCD_Init(); // Initiate MFRC522
30
+
31
+  Serial.println();
32
+
33
+  pinMode(RFIDled, OUTPUT);
34
+  pinMode(RFIDSound, OUTPUT);
35
+  pinMode(RFIDbin, OUTPUT);
36
+  pinMode(signalIN, INPUT);
37
+  pinMode(TextKnob, INPUT);
38
+  pinMode(textSound, OUTPUT);
39
+}
40
+
41
+void readCard() {
42
+  // Look for new cards
43
+  if ( ! mfrc522.PICC_IsNewCardPresent())
44
+  {
45
+    return;
46
+  }
47
+  // Select one of the cards
48
+  if ( ! mfrc522.PICC_ReadCardSerial())
49
+  {
50
+    return;
51
+  }
52
+
53
+  //Show UID on serial monitor
54
+  Serial.print("UID tag :");
55
+  String content = ""; // for tag + sound
56
+  String binary = ""; // for binary + LED
57
+
58
+  for (int i = 0; i < mfrc522.uid.size; i++)
59
+  {
60
+    Serial.print(mfrc522.uid.uidByte[i], DEC);
61
+    content.concat(String(mfrc522.uid.uidByte[i], DEC));
62
+
63
+    if (content.charAt(i) == '0') {
64
+      tone(RFIDSound, 40, 2250);
65
+      delay(100);
66
+    }
67
+    else if (content.charAt(i) == '1') {
68
+      tone(RFIDSound, 15, 2250);
69
+      delay(100);
70
+    }
71
+    else if (content.charAt(i) == '2') {
72
+      tone(RFIDSound, 25, 1500);
73
+      delay(100);
74
+    }
75
+    else if (content.charAt(i) == '3') {
76
+      tone(RFIDSound, 17, 150);
77
+      delay(100);
78
+    }
79
+    else if (content.charAt(i) == '4') {
80
+      tone(RFIDSound, 30, 1000);
81
+      delay(100);
82
+    }
83
+    else if (content.charAt(i) == '5') {
84
+      tone(RFIDSound, 27, 1590);
85
+      delay(100);
86
+    }
87
+    else if (content.charAt(i) == '6') {
88
+      tone(RFIDSound, 28, 1500);
89
+      delay(100);
90
+    }
91
+    else if (content.charAt(i) == '7') {
92
+      tone(RFIDSound, 10, 1500);
93
+      delay(100);
94
+    }
95
+    else if (content.charAt(i) == '8') {
96
+      tone(RFIDSound, 13, 1050);
97
+      delay(100);
98
+    }
99
+    else if (content.charAt(i) == '9') {
100
+      tone(RFIDSound, 7, 1000);
101
+      delay(100);
102
+    }
103
+  }
104
+
105
+  for (int b = 0; b < mfrc522.uid.size; b++)
106
+  {
107
+    Serial.println(mfrc522.uid.uidByte[b], BIN);
108
+    char r = mfrc522.uid.uidByte[b];
109
+
110
+    for (int j = 8; j >= 0; j--) {
111
+      if CHECK_BIT(r, j) {
112
+        digitalWrite(RFIDled, HIGH);
113
+        digitalWrite(RFIDbin, HIGH);
114
+        delay(100);
115
+      } else {
116
+        digitalWrite(RFIDled, LOW);
117
+        digitalWrite(RFIDbin, LOW);
118
+        delay(100);
119
+      }
120
+      delay(100);
121
+    }
122
+  }
123
+  Serial.println();
124
+  delay(100);
125
+}
126
+
127
+//Q-code questions
128
+const char *Qs[] = {
129
+  "",
130
+  "",
131
+  "QRB?:How far are you from my station?",
132
+  "QRL?:Are you busy?",
133
+  "QRZ?:Who is calling me?",
134
+  "QRH?:Does my frequency vary?",
135
+  "QRI?:How is the tone of my transmission?",
136
+  "QRK?:What is the readability of my signals?",
137
+  "QRM?:Do you have interference?",
138
+  "QRN?:Are you troubled by static noise?",
139
+  "QRQ?:Shall I send faster?",
140
+  "QRT?:Shall I cease or suspend operation?",
141
+  "QRU?:Have you anything for me?",
142
+  "QRV?:Are you ready?",
143
+  "QRX?:Shall I standby?",
144
+  "QSA?:What is the strength of my signals?",
145
+  "QSB?:Are my signals fading?",
146
+  "QSD?:Is my keying defective?",
147
+  "QSL?:Can you acknowledge receipt?"
148
+};
149
+
150
+//Q-code answers/statements
151
+const char *As[] = {
152
+  "QRH:Your frequency varies.",
153
+  "QRL:I am busy. Please do not interfere.",
154
+  "QRM:I have interference.",
155
+  "QRM:I am troubled by static noise.",
156
+  "QRO:Please increase transmit power.",
157
+  "QRQ:Please send faster.",
158
+  "QRS:Please send more slowly",
159
+  "QRT:I am suspending operation.",
160
+  "QRU:I have nothing for you.",
161
+  "QRV:I am ready.",
162
+  "QRX:Please standby.",
163
+  "QSB:Your signals are fading.",
164
+  "QSD:Your keying is defective.",
165
+  "QSK:I can hear you between my signals (while transmitting); break in on my transmission.",
166
+  "QSL:I am acknowledging receipt.",
167
+  "QSM:Repeat the last telegram which you sent me",
168
+  "QSY:Please change transmission frequency.",
169
+  "QSZ:Send each word or group twice."
170
+};
171
+
172
+void loop()
173
+{
174
+  readCard();
175
+  int textnumber;
176
+  int text = analogRead(TextKnob);
177
+  textnumber = map(text, 1, 1023, 0, 18);
178
+
179
+  if (textnumber > 1) { //when the knob is turned from the 'position 0'
180
+    Serial.println(Qs[textnumber]);
181
+    String question = Qs[textnumber];
182
+    lcd.setCursor(0, 0); //Set the lcd cursor to the upper left corner
183
+    lcd.print(Qs[textnumber]); //Display the specific Q-question on the fisrt row of LCD
184
+
185
+    for (int positionCounter = 0; positionCounter < question.length(); positionCounter++) {
186
+      lcd.scrollDisplayLeft(); //Q-question scrolls to the left
187
+      delay(230);
188
+    }
189
+    char* specQs = Qs[textnumber];
190
+
191
+    // loop over each character of question
192
+    for (int a = 0; a < strlen(specQs); a++ ) {
193
+      char c = specQs[a];
194
+      //Serial.print(c);
195
+      //Serial.print(" ");
196
+      Serial.print(specQs[a], BIN);
197
+      //Serial.println();
198
+
199
+      // sonify the bits...
200
+      for (int i = 7; i >= 0; i--) {
201
+        if CHECK_BIT(c, i) {
202
+          tone(textSound, 440, 100);
203
+        } else {
204
+          tone(textSound, 220, 100);
205
+        }
206
+        delay(100);
207
+      }
208
+    }
209
+  }
210
+
211
+
212
+  // give an answer
213
+  randNumber = random(0, 17);
214
+  int readSignal = digitalRead(signalIN);
215
+  String randomQ = As[randNumber];
216
+
217
+  if (readSignal) { //If the module receives a signal via A2 o4 input channel...
218
+    Serial.println(As[randNumber]);
219
+    lcd.setCursor(0, 1); //Set the lcd cursor to the lower left corner
220
+    lcd.print(randomQ); //Displayes a random Q-answer from the answers array
221
+
222
+    for (int counter = 0; counter < randomQ.length(); counter++) {
223
+      lcd.scrollDisplayLeft(); //Q-answer dissapears in the left side of the LCD
224
+      delay(230);
225
+    }
226
+  }
227
+  delay(500);
228
+}

Loading…
Cancel
Save