-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.ino
108 lines (99 loc) · 2 KB
/
project.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <LiquidCrystal.h>
String voice;
String old;
String encrypt="";
String encrypt2="";
String morse[26]={".-","-...","-.-.","-..",".","..-.","--.","....","..",
".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-",
"...-",".--","-..-","-.--","--.."};
char ch;
const int rs = 12, en = 11, d4 = 2, d5 = 3, d6 = 4, d7 = 5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
// put your main code here, to run repeatedly:
while (Serial.available())
{
delay(10);
char c = Serial.read();
if (c == '#') {break;}
voice += c;
}
if (voice.length() > 1) {
Serial.println("\n"+voice);
//ROT-13 Encryption
for(int i=0;i<voice.length();i++)
{
int num=voice[i];
if(num>=65 && num<=90)
{
num=num%65;
num=num+13+65;
if(num>90)
{
int rem=num%91;
num=65+rem;
}
ch=num;
}
if(num>=97 && num<=122)
{
num=num%97;
num=num+13+97;
if(num>122)
{
int rem=num%123;
num=97+rem;
}
ch=num;
}
if(num==32)
{
ch=num;
}
if(encrypt.length()<voice.length())
{
encrypt=encrypt+ch;
}
}
//Morse Code Encryption
for(int i=0;i<voice.length();i++)
{
int num2=voice[i];
if(num2>=65 && num2<=90)
{
num2=num2%65;
encrypt2+=morse[num2];
encrypt2+=" ";
}
if(num2>=97 && num2<=122)
{
num2=num2%97;
encrypt2+=morse[num2];
encrypt2+=" ";
}
if(num2==32)
{
encrypt2+=" ";
}
}
Serial.println(encrypt);
Serial.println(encrypt2);
}
Serial.print(" ");
lcd.setCursor(0,0);
lcd.print(encrypt2);
lcd.setCursor(0,1);
lcd.print(encrypt);
for (int positionCounter = 0; positionCounter < 3; positionCounter++) {
lcd.scrollDisplayLeft();
}
delay(1000);
voice="";
encrypt="";
encrypt2="";
}