Arduino_BlinkWithoutDelay_Timer sample code ported.

Dependencies:   mbed

Committer:
homayoun
Date:
Wed Sep 03 10:59:19 2014 +0000
Revision:
0:9dccd331cbdc
Arduino_BlinkWithoutDelay_Timer sample code ported.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
homayoun 0:9dccd331cbdc 1 #include "mbed.h"
homayoun 0:9dccd331cbdc 2
homayoun 0:9dccd331cbdc 3 DigitalOut myled(LED1);
homayoun 0:9dccd331cbdc 4 Timer t;
homayoun 0:9dccd331cbdc 5 int interval = 1000;
homayoun 0:9dccd331cbdc 6
homayoun 0:9dccd331cbdc 7 void setup()
homayoun 0:9dccd331cbdc 8 {
homayoun 0:9dccd331cbdc 9 t.start();
homayoun 0:9dccd331cbdc 10 }
homayoun 0:9dccd331cbdc 11
homayoun 0:9dccd331cbdc 12 void loop()
homayoun 0:9dccd331cbdc 13 {
homayoun 0:9dccd331cbdc 14 if(t.read_ms() > interval) {
homayoun 0:9dccd331cbdc 15 t.reset();
homayoun 0:9dccd331cbdc 16 myled = !myled;
homayoun 0:9dccd331cbdc 17 }
homayoun 0:9dccd331cbdc 18 }
homayoun 0:9dccd331cbdc 19
homayoun 0:9dccd331cbdc 20 int main()
homayoun 0:9dccd331cbdc 21 {
homayoun 0:9dccd331cbdc 22 setup();
homayoun 0:9dccd331cbdc 23 while(1) loop();
homayoun 0:9dccd331cbdc 24 }