For my second tech demo, I wanted to make a project using flashing LEDs to display morse code. After several failed attempts at using different codes and/or libraries to accomplish this, I found a morse code library that turned the complex task into some very simple code and with a few easy changes I could modify to work for four LEDs rather than one.
#include <ArduinoMorse.h> ArduinoMorse morse1(5); ArduinoMorse morse2(6); ArduinoMorse morse3(7); ArduinoMorse morse4(8); const int LED1 (5); const int LED2 (6); const int LED3 (7); const int LED4 (8); void setup() { delay(1000); } void loop() { // Flash in morse code: morse3.process("Do"); delay(50); morse4.process("you"); delay(50); morse3.process("bite"); delay(50); morse4.process("your"); delay(50); morse3.process("thumb"); delay(50); morse4.process("at"); delay(50); morse3.process("us"); delay(50); morse4.process("sir"); delay(500); morse1.process("I"); delay(50); morse2.process("do"); delay(50); morse1.process("bite"); delay(50); morse2.process("my"); delay(50); morse1.process("thumb"); delay(50); morse2.process("sir"); delay(500); pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); pinMode(LED4, OUTPUT); digitalWrite(LED2, HIGH); delay(1000); digitalWrite(LED1, HIGH); delay(1000); digitalWrite(LED4, HIGH); delay(1000); digitalWrite(LED3, HIGH); delay(1000); exit (0); }
Sources:
https://github.com/willvincent/ArduinoMorse
https://www.marginallyclever.com/2014/11/how-to-blink-morse-code-with-arduino/
https://makezine.com/projects/arduino-morse-code-flasher/
Leave a Reply
You must be logged in to post a comment.