Solution to Task 1.2.1

Fork of Task121Solution by Nicholas Outram

Committer:
noutram
Date:
Thu Sep 24 12:24:01 2015 +0000
Revision:
0:f809b34da5df
Child:
1:120c820502a2
Initial version 24-09-2015

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noutram 0:f809b34da5df 1 #include "mbed.h"
noutram 0:f809b34da5df 2
noutram 0:f809b34da5df 3 //This is my solution, using C functions
noutram 0:f809b34da5df 4 //to avoid repetition.
noutram 0:f809b34da5df 5
noutram 0:f809b34da5df 6 DigitalOut myled(D7);
noutram 0:f809b34da5df 7
noutram 0:f809b34da5df 8 void flash(double t);
noutram 0:f809b34da5df 9 void dash();
noutram 0:f809b34da5df 10 void dot();
noutram 0:f809b34da5df 11 void symbGap() ;
noutram 0:f809b34da5df 12
noutram 0:f809b34da5df 13 int main() {
noutram 0:f809b34da5df 14 while(1) {
noutram 0:f809b34da5df 15 dot();
noutram 0:f809b34da5df 16 dot();
noutram 0:f809b34da5df 17 dot();
noutram 0:f809b34da5df 18 symbGap();
noutram 0:f809b34da5df 19 dash();
noutram 0:f809b34da5df 20 dash();
noutram 0:f809b34da5df 21 dash();
noutram 0:f809b34da5df 22 symbGap();
noutram 0:f809b34da5df 23 dot();
noutram 0:f809b34da5df 24 dot();
noutram 0:f809b34da5df 25 dot();
noutram 0:f809b34da5df 26 wait(5.0);
noutram 0:f809b34da5df 27 }
noutram 0:f809b34da5df 28 }
noutram 0:f809b34da5df 29
noutram 0:f809b34da5df 30 void dot() {
noutram 0:f809b34da5df 31 flash(0.15);
noutram 0:f809b34da5df 32 }
noutram 0:f809b34da5df 33
noutram 0:f809b34da5df 34 void symbGap() {
noutram 0:f809b34da5df 35 wait(0.15);
noutram 0:f809b34da5df 36 }
noutram 0:f809b34da5df 37
noutram 0:f809b34da5df 38 void dash() {
noutram 0:f809b34da5df 39 flash(0.45);
noutram 0:f809b34da5df 40 }
noutram 0:f809b34da5df 41
noutram 0:f809b34da5df 42 void flash(double t) {
noutram 0:f809b34da5df 43 myled = 1;
noutram 0:f809b34da5df 44 wait(t);
noutram 0:f809b34da5df 45 myled=0;
noutram 0:f809b34da5df 46 wait(0.15);
noutram 0:f809b34da5df 47 }