I want a code where the LDR receives the signal from LASER and converts the morse code into original text and displays it into the 20*4 LED display??
If anyone has it please give it to me it would help me for my project??
I want a code where the LDR receives the signal from LASER and converts the morse code into original text and displays it into the 20*4 LED display??
If anyone has it please give it to me it would help me for my project??
I was just looking at some this morning:
https://nullprogram.com/blog/2020/12/31/
//...this deterministic state machine for decoding Morse
// code. It accepts a dot ('.'), dash ('-'), or terminator (0) one
// at a time, advancing through a state machine step by step:
int morse_decode(int state, int c)
{
static const unsigned char t[] = {
0x03, 0x3f, 0x7b, 0x4f, 0x2f, 0x63, 0x5f, 0x77, 0x7f, 0x72,
0x87, 0x3b, 0x57, 0x47, 0x67, 0x4b, 0x81, 0x40, 0x01, 0x58,
0x00, 0x68, 0x51, 0x32, 0x88, 0x34, 0x8c, 0x92, 0x6c, 0x02,
0x03, 0x18, 0x14, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x24,
0x00, 0x28, 0x04, 0x00, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a
};
int v = t[-state];
switch (c) {
case 0x00: return v >> 2 ? t[(v >> 2) + 63] : 0;
case 0x2e: return v & 2 ? state*2 - 1 : 0;
case 0x2d: return v & 1 ? state*2 - 2 : 0;
default: return 0;
}
}
// It typically compiles to under 200 bytes (table included),
// requires only a few bytes of memory to operate, and will
// fit on even the smallest of microcontrollers. The full
// source listing, documentation, and comprehensive test
// suite:
// https://github.com/skeeto/scratch/blob/master/misc/morsecode.c
Does this do the same as i have mentioned or is it little bit different?
Chances are you won't "find" code that does exactly what you want, at least not for free. So, you can either adapt existing code to your needs or pay someone to do your work for you.
The above code does not even run in arduino mega so it is hard
The above code does not even run in arduino mega
I wonder what your mistake(s) might be.
Correct it will not run by itself, it is only the "clever bit" that does the decoding. You have to feed it with the right data. Are you doing that?
If anyone has the code to connect your specific LASER, LDR, and 20*4
display to your Arduino, it would probably be a person who has your specific LASER, LDR, 20*4
display, and Arduino.
A mores code decoder was the first embedded project I did, back in 1976. But it was written in 2650 machine code, note not even assembler.
What would surprise me is if a laser on an LDR would produce a signal fast and clear enough. An LDR has a large surface area compared to a laser spot so it would not drop very much when hit with the laser. Also a LDR is slow to drop in resistance when the light is removed.
You can use a photo transistor in place of the physical Morse key:
https://forum.arduino.cc/t/break-the-morse-code-speed-barrier/165039
I attached zip that compiles with most recent IDE 1.8.18
2x16 Display version for UNO, ProMicro
Magic_Morse_V6.zip (5.9 KB)
Sketch uses 6052 bytes (18%) of program storage space. Maximum is 32256 bytes.
Global variables use 290 bytes (14%) of dynamic memory, leaving 1758 bytes for local variables. Maximum is 2048 bytes.
The idea is really old, first implemented on PICAXE. The algorithm is reversible.
Notes: https://picaxeforum.co.uk/threads/notes-behind-magic-morse.30873/
I used the reversal to create a visual temperature project, the thermistor provided the temp and a LED flashed the Morse once a minute. It was intended for outside, but cheap wireless came along before I built the solar power supply.
So old, my cellphone camera only had 1 pixel:
https://youtu.be/c9qKYAINwHA
a simple morse decoder could use a structure such as
// structure to hold character and its morse code
struct morse {
char letter;
char code[6];
};
// array defining charracters and equivalent codes
struct morse morse_code[]= {
{'A' , ".-"},
{'B' , "-..."},
{'C' , "-.-."},
{'D' , "-.."},
{'E' , "."},
{'F' , "..-."},
{'G' , "--."},
{'H' , "...."},
{'I' , ".."},
{'J' , ".---"},
};
int main(void) {
printf("number of characters in array %d\n", sizeof(morse_code)/sizeof(morse_code[0]));
printf("element morse_code[7] character %c code %s\n\n", morse_code[7].letter, morse_code[7].code);
}
a run gives
number of characters in array 10
element morse_code[7] character H code ....
add statements to read a string then itterate thru the array morse_code[] comparing the string read with each element morse_code[].code - when you have a match morse_code[].letter gives you the result
and you have explained the hurdle... Morse comes in as dots/dits and dashes/dahs. There is no carriage return and the speed is clocked by a human, not consistent.
So, were one receiving ASCII from the serial port, your idea is grand. Otherwise, the character must be developed individually from the raw elements. Not hard, but a bit of thought is involved in handling Morse keying speed. Ham radio operators can often identify the identity of the sender from the cadence.
Magic Morse simplifies the lookup by weighting the incoming position of "dash" pulses to create a matrix lookup:
// ITU (International Morse Code) decoding: The MM[] matrix is decoded in 6-elements to provide for prosigns
// http://upload.wikimedia.org/wikipedia/en/thumb/5/5a/Morse_comparison.svg/350px-Morse_comparison.svg.png
PROGMEM char const MM[] = "_EISH5ee0TNDB6-0" // 0 - 15 e == ERROR
"00ARLw0000MGZ700" // 16 - 31 w == WAIT
"000UF0000i0KC000" // 32 - 47 i == INVITE
"000WP000000O0800" // 48 - 63
"0000Vu]00000X/00" // 64 - 79 u == UNDERSTOOD ] == End Of Work
"00000+.00000Q000" // 80 - 95
"000000?00000Y()0" // 96 - 111 () == Left/Right hand bracket
"0000J0000000e900" // 112 - 127
"000004(c) M.R=BU" // 128 - 143
"RNETTE'0000000,0" // 144 - 159 ' @ [150] should be "
"00>0000000000[00" // 160 - 175 [ == Starting Signal
"000000@000000000" // 176 - 191
"0000030000000000" // 192 - 207
"0000000000000000" // 208 - 223
"0000020000000000" // 224 - 239
"000001'000000000"; // 240 - 255
void ReadMorseKeyState()
{
TimeStamp = millis();
// Read state of Morse Code digital input
MorseKeyState = !digitalRead(morseInPin); // ActiveLow so inverse: key closed, MorseKeyState = true
// Noise suspression
if (MorseKeyState != PreviousKeyState)
DeBounce = TimeStamp; // reset timer
// Debounce
if ((TimeStamp - DeBounce) > debounceDelay)
{
// take whatever the current state reading is after the debounce time
CurrentKeyState = MorseKeyState;
// differentiante keyDOWN and keyUP times
if (CurrentKeyState) {
tone(toneOutPin, toneHz);
keyDOWN = DeBounce;
SignalFlag = false;
SingleSpace = false;
} //end if (CurrentKeyState)
else {
keyUP = DeBounce;
noTone(toneOutPin); } // else
} //end if ((TimeStamp - DeBounce) > debounceDelay)
} // end ReadMorseKeyState
And just as important are the SPACES between dots and dashes and words.
For use with pulsed laser and photo-transistor, the debounce code may not be necessary - depending on how clean the distant end code source is designed.
I guess someone had to say it! Glad it was a friend.
Ver 8a from forum link has a helpful analyzer mode to assist with rhythm:
void STATUS (void)
{
if (!digitalRead(VerbosePin)); {
Serial << (F("DIT: ")) << DITmS <<(F(" mS "));
Serial << (F("DIT range: > ")) << quarterDIT << (F(" < ")) << halfDAH << (F(" mS")) << endl;
Serial << (F("DAH: ")) << DAHmS <<(F(" mS "));
Serial << (F("DAH range: >= ")) << halfDAH << (F(" < ")) << DITDAH << (F(" mS")) << endl;
Serial << (F("Char Break: >= ")) << DiDiDi << (F(" < ")) << wordBreak << (F(" mS")) << endl;
Serial << (F("Word Break: >= ")) << wordBreak << (F(" mS")) << endl << endl;
}
}
It will also send a tone for set speed based on PARIS
`
char PARIS(byte Letter)
{
switch(Letter)
{
case 0: // P
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin,toneHz); delay(DAHmS); // <dah>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin,toneHz); delay(DAHmS); // <dah>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
return 'P';
case 1: // A
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin,toneHz); delay(DAHmS); // <dah>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
return 'A';
case 2: // R
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin,toneHz); delay(DAHmS); // <dah>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
return 'R';
case 3: // I
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
return 'I';
case 4: //S
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin);
return 'S';
}
}
`
Chances are you won't "find" code that does exactly what you want, at least not for free.
Sadly, this is often the case; however, some "sold" code uses open-source software as be basis of the product. This is a sad statement.
I strongly encourage forum members to not feather the nests of these sellers; rather, learn to do a thorough Internet search before giving away your money.
Ray
a lot since i am just a newbie
I made a morse code interpreter with basic components and Arduino UNO.. It encodes text to morse code and decodes morse code to text within the serial monitor and gives output via a buzzer and a led.. and takes input through a push switch. The problem is that when i task it to encode text to morse, It only does it after decoding something.. Is there a fix so that i can use both encoding and decoding in no particuar order.. I will attach the code and diagram.. I'm new to coding. so a help will…