we could do to Create a link (program or interface (no external components)) between Morse
and a flashlight and that should blink with respective to Morse
but could not do to .Create another program to record the flash and that flash-toggling should be
again reconverted into Morse and then decrypted into text.
in tinker cad the photodiode or ldr is not varied depending the lightβ¦(.it should be varied manully in tinker cadβ¦)
i need the photo diode or ldr to vary automatically on the change of led
i will attach the code and snip of tinker cad ,better if you do it on ther platform and share β¦plz
transmitter code
const char* MorseTable[] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
// space, !, ", #, $, %, &, β
NULL, β-.-.ββ, β.-β¦-.β, NULL, NULL, NULL, NULL, β.----.β,
// ( ) * + , - . /
β-.β.β, β-.β.-β, NULL, β.-.-.β, βββ¦ββ, β-β¦-β, β.-.-.-β, β-β¦-.β,
// 0 1 2 3 4 5 6 7
β-----β, β.----β, ββ¦ββ, ββ¦ββ, ββ¦-β, ββ¦β, β-β¦β, βββ¦β,
// 8 9 : ; < = > ?
βββ¦β, β----.β, βββ¦β, β-.-.-.β, NULL, β-β¦-β, NULL, ββ¦ββ¦β,
// @ A B C D E F G
β.β.-.β, β.-β, β-β¦β, β-.-.β, β-β¦β, β.β, ββ¦-.β, ββ.β,
// H I J K L M N O
ββ¦β, ββ¦β, β.ββ, β-.-β, β.-β¦β, βββ, β-.β, βββ,
// P Q R S T U V W
β.β.β, ββ.-β, β.-.β, ββ¦β, β-β, ββ¦-β, ββ¦-β, β.ββ,
// X Y Z [ \ ] ^ _
β-β¦-β, β-.ββ, βββ¦β, NULL, NULL, NULL, NULL, ββ¦β.-β,
// β a b c d e f g
NULL, β.-β, β-β¦β, β-.-.β, β-β¦β, β.β, ββ¦-.β, ββ.β,
// h i j k l m n o
ββ¦β, ββ¦β, β.ββ, β-.-β, β.-β¦β, βββ, β-.β, βββ,
// p q r s t u v w
β.β.β, ββ.-β, β.-.β, ββ¦β, β-β, ββ¦-β, ββ¦-β, β.ββ,
// x y z { | } ~ DEL
β-β¦-β, β-.ββ, βββ¦β, NULL, NULL, NULL, NULL, NULL,
};
int dotLength = 50;
int dashLength = dotLength*3;
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop() {
char ch;
if(Serial.available()){
ch = Serial.read();
flashDashDot(MorseTable[ch]);
delay(dotLength*2);
}
}
void flashDashDot(const char * morseCode)
{
int i = 0;
while(morseCode[i] != 0)
{
if(morseCode[i] == β.β){
dot();
} else if (morseCode[i] == β-β){
dash();
}
i++;
}
}
void dot()
{
digitalWrite(13, HIGH);
delay(dotLength);
digitalWrite(13, LOW);
delay(dotLength);
}
void dash()
{
digitalWrite(13, HIGH);
delay(dashLength);
digitalWrite(13, LOW);
delay(dotLength);
}
Receiver code
//Morse Code Binary Tree
// Left child at 2n+1
// Right child at 2n+2
// <.|->
// .E -T
// .I -A .N -M
//
const char MorseTree[] = {β\0β,βEβ, βTβ, βIβ, βAβ, βNβ, βMβ, βSβ,
βUβ, βRβ, βWβ, βDβ, βKβ, βGβ, βOβ, βHβ,
βVβ, βFβ, βUβ, βLβ, βAβ, βPβ, βJβ, βBβ,
βXβ, βCβ, βYβ, βZβ, βQβ, β\0β,β\0β,β5β,
β4β, β\0β,β3β, β\0β,β\0β,β\0β,β2β, β\0β,
β\0β,β+β, β\0β,β\0β,β\0β,β\0β,β1β, β6β,
β=β, β/β, β\0β,β\0β,β\0β,β(β, β\0β,β7β,
β\0β,β\0β,β\0β,β8β, β\0β,β9β, β0β, β\0β,
β\0β,β\0β,β\0β,β\0β,β\0β,β\0β,β\0β,β\0β,
β\0β,β\0β,β\0β,β?β, β_β, β\0β,β\0β,β\0β,
β\0β,β"β, β\0β,β\0β,β.β, β\0β,β\0β,β\0β,
β\0β,β@β, β\0β,β\0β,β\0β,β\0β,β\0β,β\0β,
β-β, β\0β,β\0β,β\0β,β\0β,β\0β,β\0β,β\0β,
β\0β,β;β, β!β, β\0β,β)β, β\0β,β\0β,β\0β,
β\0β,β\0β,β,β, β\0β,β\0β,β\0β,β\0β,β:β,
β\0β,β\0β,β\0β,β\0β,β\0β,β\0β,β\0β
};
int val = 0; // A Variable to Store the Light Value from the LDR
int ctrHigh = 0;
int ctrLow = 0;
int codePtr = 0;
int dotLen = 400;
void setup()
{
Serial.begin(9600);// Start a Serial Connection
Serial.print(codePtr);
}
void loop()
{
val = analogRead(4);
if (val >= 10)
{
ctrHigh++;
ctrLow = 0;
digitalWrite(13, HIGH);
tone(9, 1000);
} else {
ctrLow++;
if ((ctrHigh >= dotLen) && (ctrHigh < dotLen2)) {
Serial.print(".");
codePtr = (2codePtr) + 1;
} else if (ctrHigh >= dotLen * 2) {
Serial.print("-");
codePtr = (2codePtr) + 2;
} else {
if(ctrLow == dotLen2){
Serial.print(MorseTree[codePtr]);
codePtr = 0;
}
}
ctrHigh = 0;
digitalWrite(13, LOW);
noTone(9);
}
}
β¦
if photodiode recognizes the led light then it will decode ,but in tinker cad the photodiode is not recving the led light as shown in diagram⦠pls look into it .
even if you have any simullation please attach