Thursday, September 6, 2018

Arduino "Hello World"

Well not quite. I did a Morse Code snippet instead.


[code]
/*
SOS

Blinks the On Board LED
Prints out the "Word" on the Serial Port

  modified 6 September 2018
  by Mark Bolton

*/

int var = 0;

void setup() {
  
 Serial.begin(9600);                                         // initialize BAUD 9600 bits per second:
 pinMode(LED_BUILTIN, OUTPUT);          // initialize digital pin LED_BUILTIN as an output.
}

void loop() {

  var = 0;                                                           // loop 3 times
  while(var < 3){

  digitalWrite(LED_BUILTIN, HIGH);           // turn the LED on "DIT")
  delay(100);                        // wait
  digitalWrite(LED_BUILTIN, LOW);           // turn the LED off "SPACE"
  delay(200);
  Serial.print("DIT  ");                                     //Print the Character
  var++;
  }
    var = 0;                                                        // loop 3 times
  while(var < 3){
  var++;
  digitalWrite(LED_BUILTIN, HIGH);           // turn the LED on "DAH")
  delay(400);                                                     // wait
  digitalWrite(LED_BUILTIN, LOW);            // turn the LED off "SPACE"
  delay(200);                                                     // wait
  Serial.print("DAH  ");
  }
    var = 0;                                                        // loop 3 times
  while(var < 3){
  var++;
  digitalWrite(LED_BUILTIN, HIGH);            // turn the LED on "DIT")
  delay(100);                                                     // wait
  digitalWrite(LED_BUILTIN, LOW);            // turn the LED off "SPACE"
  delay(200);                                                     // wait
  Serial.print("DIT  ");
  }

  {
  digitalWrite(LED_BUILTIN, LOW);           // turn the LED off "END WORD"
  delay(600);                                                   // wait
  Serial.println("");
  }
}
[/code]

No comments:

Post a Comment