Note that there are some explanatory texts on larger screens.

plurals
  1. POLooping elegantly the message SOS in Arduino LED blinks
    primarykey
    data
    text
    <p>I am trying to make my Arduino blink "SOS" in Morse Code as my first real programming project ever.</p> <p>I have succeeded in doing so, however now I would like to more efficiently write the code. Here is the my version. How can a while loop be implemented to get the S blinking twice? That seems to complicate keeping track of iterations with a counter.</p> <pre><code>int led = 13; //yj Integer representing dit (morse ' . ') int dit = 500; //yj Integer representing dah (morse ' - '&gt;) //yj Testing a multiple of another constant integer to make the timing scalable. int dah = dit*3; int blankTime = 100; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dit); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dit); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dit); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dah); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dah); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dah); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dit); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dit); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(dit); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(blankTime); // wait } //TODO: //Loop counter implementation for multiples (SOS = 3 dit, 3 dah, 3 dit.) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload