Yoji Shidara
/
hello
Hello World form mbed
main.cpp
- Committer:
- dara
- Date:
- 2012-02-24
- Revision:
- 0:9781dfcab99c
File content as of revision 0:9781dfcab99c:
#include "mbed.h" DigitalOut myled(LED1); char *morse_pattern[] = { "._", "_...", "_._.", "_..", ".", ".._.", "__.", "....", "..", ".___", "_._", "._..", "__", "_.", "___", ".__.", "__._", "._.", "...", "_", ".._", "..._", ".__", "_.._", "__._", "__.." }; void morse(float time, char *str) { int i, j; for (i=0; i<strlen(str); i++) { char *c = str+i; if ('A' <= *c && *c <= 'Z') { char *pattern = morse_pattern[*c - 'A']; for (j=0; j<strlen(pattern); j++) { myled = 1; if(pattern[j] == '.') { wait(time * 1); } else { wait(time * 3); } myled = 0; wait(time * 1); } wait(time * 2); } else { wait(time * 3); } } wait(time * 4); } int main() { char *str = "HELLO WORLD"; while(1) { morse(0.1, str); } }