Solution to Task 1.2.1

Dependencies:   mbed

Committer:
noutram
Date:
Thu Jul 13 10:09:34 2017 +0000
Revision:
1:120c820502a2
Parent:
0:f809b34da5df
121 solution

Who changed what in which revision?

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