Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int menuselect = 0;
- void setup() {
- //Initialize serial and wait for port to open:
- Serial.begin(9600);
- // prints text and menu options for user to select from
- Serial.println(F("Welcome to LED basic menu!"));
- delay(1000);
- Serial.println(F(" "));
- Serial.println(F("Please select a number from the options available"));
- Serial.println(F(" "));
- Serial.println(F("Main Menu"));
- Serial.println(F("---------"));
- Serial.println(F("1. SOS signal"));
- Serial.println(F("2. Single S signal"));
- Serial.println(F("3. Single O signal"));
- }
- void dot() {
- digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(75); // wait for a second
- digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
- delay(75); // wait for a second
- digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(75); // wait for a second
- digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
- delay(75); // wait for a second // dot
- digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(75); // wait for a second
- digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
- delay(75); // wait for a second
- }
- void dash() {
- digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
- delay(400); // wait for a second
- digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(400); // wait for a second
- digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
- delay(400); // wait for a second
- digitalWrite(LED_BUILTIN, HIGH); // turn the LED off by making the voltage LOW
- delay(400); // wait for a second //dash
- digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
- delay(400); // wait for a second
- digitalWrite(LED_BUILTIN, HIGH); // turn the LED off by making the voltage LOW
- delay(400); // wait for a second
- digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
- delay(400); // wait for a second
- }
- void loop()
- {
- char ch;
- if (Serial.available()) //Constantly checks to see if anything has been sent over the USB Connection and if it needs to be processed
- {
- menuselect = Serial.read(); //Reads a single letter
- if (menuselect == '1')
- {
- //Serial.flush();//Try to clear the serial monitor and then go to conversion
- delay(1000);
- dot();
- dash();
- dot();
- }
- if (menuselect == '2')
- {
- //Serial.flush();//Try to clear the serial monitor and then go to conversion
- delay(1000);
- dot();
- }
- if (menuselect == '3')
- {
- //Serial.flush();//Try to clear the serial monitor and then go to conversion
- delay(1000);
- dash();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement