Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- 자바정리
- java
- 개발
- 사물인터넷
- 자바독학
- 개인프로젝트
- 백준
- backend
- Project
- 자바
- Python
- 모의 주식
- 프로그램
- frontend
- 코테
- 프로그래밍
- SNS
- 이웃한 칸
- 코딩테스트
- 프로그래머스
- Reflex
- 개발자
- 코스닥
- 빅데이터
- java정리
- 코딩독학
- C++
- 풀스택프레임워크
- 코딩
- 주가예측
Archives
- Today
- Total
Creative Code
11_timer1_led 본문
#include <TimerOne.h>
const int LED = 10; // timer1 을 쓰기위해서는 9,10번핀에 연결
int ledflag = 0;
void timerIsr(void) {
if (ledflag == 0) {
digitalWrite(LED,HIGH);
ledflag = 1;
} else {
digitalWrite(LED,LOW);
ledflag = 0;
}
}
void setup() {
// put your setup code here, to run once:
pinMode(LED,OUTPUT);
Timer1.initialize(1000000);
//Timer1.pwm(LED,0); //timer1을 이용하여 pwm기능을 사용하는 경우 설정
Timer1.attachInterrupt(timerIsr); // Timer1 인터럽트 기능을 사용하는 경우 설정 (주기마다 원하는 기능을 실행하는 함수)
//pwm기능과 attachInterrupt 기능을 같이 사용하면 안된다.
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 0; i<1024; i++) {
Timer1.setPwmDuty(LED,i);
delay(i);
}
}
'Arduino(C,C++)' 카테고리의 다른 글
13_PCINT_ultrasonic(timer1함수를 이용한 거리측정) (0) | 2023.08.14 |
---|---|
12_timer1_piezo (0) | 2023.08.14 |
10_ultrasonic(초음파 거리재기) (0) | 2023.08.11 |
09_tone (0) | 2023.08.11 |
08_joystick (0) | 2023.08.11 |