UoD_ME21001_Group_1_16 / Mbed 2 deprecated Exercise1

Dependencies:   mbed

main.cpp

Committer:
loicb2000
Date:
2019-10-08
Revision:
0:580af977fe72

File content as of revision 0:580af977fe72:


#include "mbed.h"

DigitalOut myled(LED1);  // use onboard LED #1

int main() {

  int mycounter;
  int flashtimes;

  while(1) {                                                // repeat the program indefinitely
    for(flashtimes=0;flashtimes<5;flashtimes++) {           // repeat five times
      for(mycounter=0;mycounter<=flashtimes;mycounter++) {  // repeat 'flashtimes' number
        myled = 1;                                          // turn on LED #1
        wait(0.250);                                        // 250ms 'on' time
        myled = 0;                                          // turn off LED #1
        wait(0.250);                                        // 250ms 'off' time
      }
      wait(1.000);                                          // 1s pause
    }

    for(flashtimes=5;flashtimes>0;flashtimes--) {           // repeat five times
      for(mycounter=0;mycounter<flashtimes;mycounter++) {   // repeat 'flashtimes' number
        myled = 1;                                          // turn on LED #1
        wait(0.250);                                        // 250ms 'on' time
        myled = 0;                                          // turn off LED #1
        wait(0.250);                                        // 250ms 'off' time
      }
      wait(1.000);                                          // 1s pause
    }
  }
}