Nicholas Outram / Mbed 2 deprecated Task121Solution

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 //This is my solution, using C functions to avoid repetition.
00004 
00005 DigitalOut myled(D7);
00006 
00007 void flash(double t);
00008 void dash();
00009 void dot();
00010 void symbGap() ;
00011 
00012 int main() {
00013     while(1) {
00014         dot();
00015         dot();
00016         dot();
00017         symbGap();
00018         dash();
00019         dash();
00020         dash();
00021         symbGap();
00022         dot();
00023         dot();
00024         dot();
00025         wait(5.0);
00026     }
00027 }
00028 
00029 void dot() {
00030     flash(0.15);
00031 }
00032 
00033 void symbGap() {
00034     wait(0.15);
00035 }
00036 
00037 void dash() {
00038     flash(0.45);
00039 }
00040 
00041 void flash(double t) {
00042     myled = 1;
00043     wait(t);
00044     myled=0; 
00045     wait(0.15);   
00046 }