DFRobot
/
millis_demo
millis_demo
Fork of mbed_blinky by
main.cpp@7:4ff2cd962710, 2014-10-31 (annotated)
- Committer:
- lisper
- Date:
- Fri Oct 31 08:07:49 2014 +0000
- Revision:
- 7:4ff2cd962710
- Parent:
- 4:81cea7a352b0
millis_demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lisper | 7:4ff2cd962710 | 1 | /* |
lisper | 7:4ff2cd962710 | 2 | * Copyright: DFRobot |
lisper | 7:4ff2cd962710 | 3 | * license: GPL |
lisper | 7:4ff2cd962710 | 4 | * Author: lisper (lisper.li@dfrobot.com) |
lisper | 7:4ff2cd962710 | 5 | * Date: 2014-10-30 |
lisper | 7:4ff2cd962710 | 6 | * Description: example program for millis library |
lisper | 7:4ff2cd962710 | 7 | */ |
dan | 0:7dec7e9ac085 | 8 | |
lisper | 7:4ff2cd962710 | 9 | #include "mbed.h" |
lisper | 7:4ff2cd962710 | 10 | #include "millis.h" |
lisper | 7:4ff2cd962710 | 11 | |
dan | 0:7dec7e9ac085 | 12 | |
lisper | 7:4ff2cd962710 | 13 | DigitalOut led1(LED1); |
lisper | 7:4ff2cd962710 | 14 | |
lisper | 7:4ff2cd962710 | 15 | int main() |
lisper | 7:4ff2cd962710 | 16 | { |
lisper | 7:4ff2cd962710 | 17 | startMillis (); //must call this function if you want use millis (); |
lisper | 7:4ff2cd962710 | 18 | |
lisper | 7:4ff2cd962710 | 19 | led1 = 0; |
lisper | 7:4ff2cd962710 | 20 | uint32_t lastTime = 0; |
lisper | 7:4ff2cd962710 | 21 | |
lisper | 7:4ff2cd962710 | 22 | while (1) { |
lisper | 7:4ff2cd962710 | 23 | if (millis() - lastTime > 1000) { |
lisper | 7:4ff2cd962710 | 24 | lastTime = millis (); |
lisper | 7:4ff2cd962710 | 25 | led1 = !led1; |
lisper | 7:4ff2cd962710 | 26 | } |
stevep | 4:81cea7a352b0 | 27 | } |
dan | 0:7dec7e9ac085 | 28 | } |