the_ledtester_class
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
the_ledtester_class [2018/08/11 01:00] – frchris | the_ledtester_class [2018/08/11 01:04] – frchris | ||
---|---|---|---|
Line 46: | Line 46: | ||
| | ||
pin1.flash(200); | pin1.flash(200); | ||
- | try { Thread.sleep200; } catch (InterruptedException e) {} | + | try { Thread.sleep(200; } catch (InterruptedException e) {} |
+ | } | ||
+ | } | ||
+ | /* | ||
+ | * Sends the morse code using the LED. | ||
+ | */ | ||
+ | public void flashMorse(String msg) { | ||
+ | |||
+ | char [] morse = StringToMorse.translate(msg).toCharArray(); | ||
+ | |||
+ | // . = 1, - = 3, intra-char = 1, inter-char = 3, space = 7.", | ||
+ | |||
+ | for (char atom : morse) { | ||
+ | if (atom == ' | ||
+ | pin1.flash(UNIT); | ||
+ | } else if (atom == ' | ||
+ | pin1.flash(3*UNIT); | ||
+ | } else if (atom == '/' | ||
+ | sleep(1; | ||
+ | } else { | ||
+ | // must be a space | ||
+ | sleep(5; | ||
+ | } | ||
+ | sleep(1; | ||
+ | } | ||
+ | } | ||
+ | /* | ||
+ | * Wait units times the defined unit of time | ||
+ | */ | ||
+ | private void sleep(int units) { | ||
+ | try { | ||
+ | Thread.sleep(units*UNIT); | ||
+ | } catch (InterruptedException e) | ||
+ | { | ||
} | } | ||
} | } |
the_ledtester_class.txt · Last modified: 2018/08/11 01:10 by frchris