I want to create a morse code for multiple leds.
Say: LED1 needs to blink the letter A, LED2 needs to blink the letter B, LED3 needs to blink the letter C.
I want these to run simultaniously (would be awesome to end at the same point, to stop the morse for five seconds, then all of the leds start over again.
But I also would like to have other read/write options for the same Arduino.
Say: command X is given from the server, digitalWrite another port (not the same as the morse code) and button Z is pressed, send A to the server.
How can I achieve the loop with an Arduino Uno, while listening to external commands
I'm using C# for my backend, connected via ComPorts to the Arduino.
I know how to use the leds and transistors, I just don't know how to program the Arduino.
In this example you will learn how the loop function can run as many times as possible while parts of the code are executed in an interval.
You can use this technique to make parts of your code seem to run all at the same time.
For this to work you must never use the delay() function again. The delay() function makes many of the examples from the IDE simple and easy to understand but stops many beginners from writing more complex sketches.
The goal of your sketch should be to run the loop function as fast as possible and call the tasks of your sketch only as often as needed. Your code should not wait for anything. Make use of state variables to remember where you are, do what needs to be done and then move on to the next task.
Try to get started, then post your code (use code tags) and ask specific questions when you need help understanding something or some hints on how to progress.
Look at the mills() function, and blink without delay, that will give you the basics you need to accomplish your task. There are many online tutorials covering this.
What you want is fairly straightforward, but ‘why?’
Morse code is essential a very low level ‘serial’ protocol... running several streams in parallel can only be for an art installation, otherwise it makes no sense at all !