Timer Örneği-3

Dependencies:   mbed

Fork of Timer_HelloWorld by mbed official

Committer:
ctasdemir
Date:
Fri May 11 05:14:11 2018 +0000
Revision:
1:f2a85aac8280
Parent:
0:27e1de20d3cb
Timer ?rne?i-3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:27e1de20d3cb 1 #include "mbed.h"
ctasdemir 1:f2a85aac8280 2
ctasdemir 1:f2a85aac8280 3 Timer timer_1;
ctasdemir 1:f2a85aac8280 4 Timer timer_2;
ctasdemir 1:f2a85aac8280 5
ctasdemir 1:f2a85aac8280 6 DigitalOut led(LED1);
ctasdemir 1:f2a85aac8280 7
mbed_official 0:27e1de20d3cb 8
ctasdemir 1:f2a85aac8280 9 void task_1(void);
ctasdemir 1:f2a85aac8280 10 void task_2(void);
mbed_official 0:27e1de20d3cb 11
mbed_official 0:27e1de20d3cb 12 int main() {
ctasdemir 1:f2a85aac8280 13 timer_1.start();
ctasdemir 1:f2a85aac8280 14 timer_2.start();
ctasdemir 1:f2a85aac8280 15 while(true){
ctasdemir 1:f2a85aac8280 16 if (timer_1.read() > 0.1) {
ctasdemir 1:f2a85aac8280 17 task_1();
ctasdemir 1:f2a85aac8280 18 timer_1.reset();
ctasdemir 1:f2a85aac8280 19 }
ctasdemir 1:f2a85aac8280 20 if (timer_2.read() > 1) {
ctasdemir 1:f2a85aac8280 21 task_2();
ctasdemir 1:f2a85aac8280 22 timer_2.reset();
ctasdemir 1:f2a85aac8280 23 }
ctasdemir 1:f2a85aac8280 24 }
mbed_official 0:27e1de20d3cb 25 }
ctasdemir 1:f2a85aac8280 26
ctasdemir 1:f2a85aac8280 27 void task_1(void) {
ctasdemir 1:f2a85aac8280 28 led = !led;
ctasdemir 1:f2a85aac8280 29 }
ctasdemir 1:f2a85aac8280 30 void task_2(void) {
ctasdemir 1:f2a85aac8280 31 static int sayac = 0;
ctasdemir 1:f2a85aac8280 32 printf("Sayac:%d \n",sayac);
ctasdemir 1:f2a85aac8280 33 sayac++;
ctasdemir 1:f2a85aac8280 34 }