Stage-1 Students SoCEM / 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
00004 //to avoid repetition.
00005 
00006 DigitalOut myled(D7);
00007 
00008 void flash(double t);
00009 void dash();
00010 void dot();
00011 void symbGap() ;
00012 
00013 int main() {
00014     while(1) {
00015         dot();
00016         dot();
00017         dot();
00018         symbGap();
00019         dash();
00020         dash();
00021         dash();
00022         symbGap();
00023         dot();
00024         dot();
00025         dot();
00026         wait(5.0);
00027     }
00028 }
00029 
00030 void dot() {
00031     flash(0.15);
00032 }
00033 
00034 void symbGap() {
00035     wait(0.15);
00036 }
00037 
00038 void dash() {
00039     flash(0.45);
00040 }
00041 
00042 void flash(double t) {
00043     myled = 1;
00044     wait(t);
00045     myled=0; 
00046     wait(0.15);   
00047 }