SHARE
TWEET

Untitled

a guest Apr 24th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int menuselect = 0;
  2.  
  3. void setup() {
  4.   //Initialize serial and wait for port to open:
  5.   Serial.begin(9600);
  6.   // prints text and menu options for user to select from
  7.   Serial.println(F("Welcome to LED basic menu!"));
  8.   delay(1000);
  9.   Serial.println(F(" "));
  10.   Serial.println(F("Please select a number from the options available"));
  11.   Serial.println(F(" "));
  12.   Serial.println(F("Main Menu"));
  13.   Serial.println(F("---------"));
  14.   Serial.println(F("1. SOS signal"));
  15.   Serial.println(F("2. Single S signal"));
  16.   Serial.println(F("3. Single O signal"));
  17. }
  18.  
  19.  
  20.  
  21.  
  22. void dot() {
  23.   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  24.   delay(75);                       // wait for a second
  25.   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  26.   delay(75);                       // wait for a second
  27.   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  28.   delay(75);                       // wait for a second
  29.   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  30.   delay(75);                       // wait for a second                                                // dot
  31.   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  32.   delay(75);                       // wait for a second
  33.   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  34.   delay(75);                       // wait for a second
  35. }
  36.  
  37. void dash() {
  38.   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  39.   delay(400);                       // wait for a second
  40.   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  41.   delay(400);                       // wait for a second
  42.   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  43.   delay(400);                       // wait for a second
  44.   digitalWrite(LED_BUILTIN, HIGH);    // turn the LED off by making the voltage LOW
  45.   delay(400);                       // wait for a second                                                //dash
  46.   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  47.   delay(400);                       // wait for a second
  48.   digitalWrite(LED_BUILTIN, HIGH);    // turn the LED off by making the voltage LOW
  49.   delay(400);                       // wait for a second
  50.   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  51.   delay(400);                       // wait for a second
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. void loop()
  62. {
  63.   char ch;
  64.   if (Serial.available())  //Constantly checks to see if anything has been sent over the USB Connection and if it needs to be processed
  65.  
  66.   {
  67.     menuselect = Serial.read(); //Reads a single letter
  68.     if (menuselect == '1')
  69.     {
  70.       //Serial.flush();//Try to clear the serial monitor and then go to conversion
  71.       delay(1000);
  72.       dot();
  73.       dash();
  74.       dot();
  75.     }
  76.     if (menuselect == '2')
  77.     {
  78.       //Serial.flush();//Try to clear the serial monitor and then go to conversion
  79.       delay(1000);
  80.       dot();
  81.  
  82.     }
  83.     if (menuselect == '3')
  84.     {
  85.       //Serial.flush();//Try to clear the serial monitor and then go to conversion
  86.       delay(1000);
  87.  
  88.       dash();
  89.     }
  90.  
  91.  
  92.   }
  93. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top