Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Ticker_3 by
Diff: main.cpp
- Revision:
- 4:af3ab097055c
- Parent:
- 3:9be917b0d07a
--- a/main.cpp Sun Oct 15 11:48:11 2017 +0000
+++ b/main.cpp Sun Oct 15 12:02:45 2017 +0000
@@ -1,36 +1,27 @@
/* Ticker : 함수를 쓰는 시간에 시작하여 원하는 시간이 지나면 특정 함수를 호출하고
다시 초기화 하여 원하는 시간이 되면 호출하는 것을 반복한다.*/
-/*결과: red_LED 5초동안 깜빡이다가 green_LED 5초동안 깜빡이는 것을 반복*/
+/*결과: red_LED 5초동안 깜빡이다가 green_LED 5초동안 on유 반복*/
#include "mbed.h"
Ticker timer;
-DigitalOut ledg(D3);
-DigitalOut ledr(D2);
-
-int flip=0;
+DigitalOut ledg(LED2);
+DigitalOut ledr(LED1);
void attime() {
- flip =!flip;
+ ledg =! ledg;
}
int main() {
+ ledg=1;
timer.attach(&attime,5); //메인 함수는 계속 실행이 되면서 5초 뒤에 attime을 호출한다. 반복적으로
+
while(1) {
- if(flip==0)
- {
- ledr =! ledr;
-
- }
- else {
-
- ledg = !ledg;
- }
-
- wait(0.2);
+ ledr =! ledr;
+ wait(0.2);
}
