Newbie here with first sketch.
Wrote code to blink red led three short times for the morse code S, then blue light three longer times for the morse code O dash, and then finally back to the short three time for the S. Need to have a delay after the red, blue ,red sequence( dot, dash, dot). If I put the code for red, then blue, then red, the program will flash two reds in a row then the blue??? I think there is an Interrupt command?
https://create.arduino.cc/editor/jimqbaum/bd2b1cf4-ff99-4d40-9425-fe9b1f4347aa/preview
No need for anything like that.
Post the code that works but doesn't yet do what you hope to accomplish.
a7
Move
pinMode(7, OUTPUT);
from loop() to setup()
Add a delay at end of loop(), e.g.
// delay(1000);
to "separate" the sequences.
Your code is missing an "S" sequence
Hi, @jimqbaum
It is best that you post your code in the post, rather than link it to the cloud.
Some platforms may not be able to read the cloud.
To add code please click this link;
You will need a letter space character and a word space character, or use multiple letter space characters.
[ S character] [letter space character] [ O character] [letter space character] [ S character] [word space character]
Thanks.. Tom..
Thanks Tom,
Not really sure relating to with the SOS space thing, however I did some reading on functions and cleaned up the whole process quite a bit. Thanks for your input.
void setup() {
pinMode(9, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
blinkLED(9, 175);
blinkLED(9, 175);
blinkLED(9, 175);
blinkLED(7,400);
blinkLED(7,400);
blinkLED(7,400);
blinkLED(9, 175);
blinkLED(9, 175);
blinkLED(9, 175);
delay(1000);
}
void blinkLED(int pin, int duration){
digitalWrite(pin, HIGH);
delay(duration);
digitalWrite(pin, LOW);
delay(duration);
}
Thanks, the tip for the delay did the trick. I did rewrite the whole code and used some function wizardry to clean up the whole process.
void setup() {
pinMode(9, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
blinkLED(9, 175);
blinkLED(9, 175);
blinkLED(9, 175);
blinkLED(7,400);
blinkLED(7,400);
blinkLED(7,400);
blinkLED(9, 175);
blinkLED(9, 175);
blinkLED(9, 175);
delay(1000);
}
void blinkLED(int pin, int duration){
digitalWrite(pin, HIGH);
delay(duration);
digitalWrite(pin, LOW);
delay(duration);
}
Don't you need to separate the letters too?
Use another delays for it
When you send morse code, you have characters, spaces between characters, and spaces between words.
So SOS when you send is;
[ S character] [letter space character] [ O character] [letter space character] [ S character] [word space character]
As you are not using an array of characters, but hard coding SOS, your method is valid but needs spaces.
Your mind decodes your output as S O S and you are really sending SOS as a single character.
or
...---... delay(1000)...---...delay(1000).
...---... is read as one character.
Wheras adding spaces between characters. and words.
... --- ...
... --- ...
... --- ...
is ;
S O S
S O S
S O S
Happy experimenting with your code.
Tom.. VK3DMK...
No, you don't. See here:
Point taken.
Just any other text or message would need character spaces.
Tom..
You need one element pause between each element, character and word. [edit] Yes, as the clip says, SOS is just an easy to remember equivalent.[/edit]
The name of symbol is SOS, and it names and stands for one character, which does sound somewhat like sending the letters S, O and S. But isn't.
Now keep your ears open and every time you hear SOS see if it wasn't really "SOS".
a7
Hey Tom,
Yes, I could use a delay between the letters. When I observed the program running it seemed appropriate. I am a Ham operator and use morse code.
Thanks,
JimQ
Correct! Yes space between the letters. When I ran the program the timing seemed appropriate.
For code sake, yes a space will be inserted.
Thanks!
Jim Q
Correct you are!
Thanks,
Jim Q
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.