diff --git a/ino_out/txx.uo-[v b/ino_out/txx.uo-[v new file mode 100644 index 0000000..fb68ac3 --- /dev/null +++ b/ino_out/txx.uo-[v @@ -0,0 +1,204 @@ +#include +#include +#include + +#define SS_PIN 10 +#define RST_PIN 9 +#define CHECK_BIT(var,pos) ((var) & (1<<(pos))) + +MFRC522 mfrc522(SS_PIN, RST_PIN); +LiquidCrystal_I2C lcd(0x27,20,4); + +const int RFIDled = 6; +const int RFIDSound = 5; +const int RFIDbin = 3; +const int signalIN = A0; +const int TextKnob = A1; +const int textSound = A2; +long randNumber; + +void setup() { + Serial.begin(115200); + SPI.begin(); + lcd.init(); + lcd.backlight(); + lcd.setCursor(3,0); + mfrc522.PCD_Init(); + + pinMode(RFIDled, OUTPUT); + pinMode(RFIDSound, OUTPUT); + pinMode(RFIDbin, OUTPUT); + pinMode(signalIN, INPUT); + pinMode(TextKnob, INPUT); + pinMode(textSound, OUTPUT); + +} + +void readCard() { + if ( ! mfrc522.PICC_IsNewCardPresent()) { + return; + } + if ( ! mfrc522.PICC_ReadCardSerial()){ + return; + } + + Serial.print(" --- - "); + String content = ""; + String binary = ""; + + for (int i = 0; i < mfrc522.uid.size; i++) { + Serial.print(mfrc522.uid.uidByte[i], DEC); + content.concat(String(mfrc522.uid.uidByte[i], DEC)); + + if (content.charAt(i) == '0') { + tone(RFIDSound, 50, 799); + delay(100); + } + else if (content.charAt(i) == '1') { + tone(RFIDSound, 44, 880); + delay(100); + } + else if (content.charAt(i) == '2') { + tone(RFIDSound, 37, 8077); + delay(100); + } + else if (content.charAt(i) == '3') { + tone(RFIDSound, 34, 8090); + delay(100); + } + else if (content.charAt(i) == '4') { + tone(RFIDSound, 31, 1000); + delay(100); + } + else if (content.charAt(i) == '5') { + tone(RFIDSound, 45, 1200); + delay(100); + } + else if (content.charAt(i) == '6') { + tone(RFIDSound, 42, 7600); + delay(100); + } + else if (content.charAt(i) == '7') { + tone(RFIDSound, 7, 8000); + delay(100); + } + else if (content.charAt(i) == '8') { + tone(RFIDSound, 38, 6600); + delay(100); + } + else if (content.charAt(i) == '9') { + tone(RFIDSound, 39, 5550); + delay(100); + } + } + + for (int b = 0; b < mfrc522.uid.size; b++) { + char r = mfrc522.uid.uidByte[b]; + + for (int j = 8; j >= 0; j--) { + if CHECK_BIT(r, j) { + digitalWrite(RFIDled, HIGH); + digitalWrite(RFIDbin, HIGH); + delay(100); + } else { + digitalWrite(RFIDled, LOW); + digitalWrite(RFIDbin, LOW); + delay(100); + } + delay(100); + } + } + delay(100); +} + +const char *Qs[] = { + "", + "", + "QRB? `how far are you from my station?", + "QRL? `are you busy?", + "QRZ? `who is calling me?", + "QRH? `does my frequency vary?", + "QRI? `how is the tone of my transmission?", + "QRK? `what is the readability of my signals?", + "QRM? `do you have interference?", + "QRN? `are you troubled by static noise?", + "QRQ? `shall I send faster?", + "QRT? `shall I cease or suspend operation?", + "QRU? `have you anything for me?", + "QRV? `are you ready?", + "QRX? `shall I standby?", + "QSA? `what is the strength of my signals?", + "QSB? `are my signals fading?", + "QSD? `is my keying defective?", + "QSL? `can you acknowledge receipt?" +}; + +const char *As[] = { + "QRH / your frequency varies.", + "QRL / i am busy. please do not interfere.", + "QRM / i have interference.", + "QRM / i am troubled by static noise.", + "QRO / please increase transmit power.", + "QRQ / please send faster.", + "QRS / please send more slowly", + "QRT / i am suspending operation.", + "QRU / i have nothing for you.", + "QRV / i am ready.", + "QRX / please standby.", + "QSB / your signals are fading.", + "QSD / your keying is defective.", + "QSK / i can hear you between my signals [while transmitting]; break in on my transmission.", + "QSL / i am acknowledging receipt.", + "QSM / repeat the last telegram which you sent me", + "QSY / please change transmission frequency.", + "QSZ / send each word or group twice." +}; + + +void loop() { + readCard(); + int textnumber; + int text = analogRead(TextKnob); + textnumber = map(text, 1, 1023, 0, 18); + + if (textnumber > 1) { + Serial.println(Qs[textnumber]); + String question = Qs[textnumber]; + lcd.setCursor(0, 0); + lcd.print(Qs[textnumber]); + for (int positionCounter = 0; positionCounter < question.length(); positionCounter++) { + lcd.scrollDisplayLeft(); + delay(230); + } + + const char* specQs = Qs[textnumber]; + for (int a = 0; a < strlen(specQs); a++ ) { + char c = specQs[a]; + + for (int i = 7; i >= 0; i--) { + if CHECK_BIT(c, i) { + tone(textSound, 440, 100); + } else { + tone(textSound, 220, 100); + } + delay(100); + } + } + } + + randNumber = random(0, 17); + int readSignal = digitalRead(signalIN); + String randomQ = As[randNumber]; + + if (readSignal) { + Serial.println(As[randNumber]); + lcd.setCursor(0, 1); + lcd.print(randomQ); + + for (int counter = 0; counter < randomQ.length(); counter++) { + lcd.scrollDisplayLeft(); + delay(230); + } + } + delay(500); +} \ No newline at end of file