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
- Reflex
- 모의 주식
- C++
- 백준
- java
- 개발
- 프로그래밍
- 코딩독학
- backend
- 사물인터넷
- 프로그래머스
- frontend
- 코테
- 이웃한 칸
- Python
- Project
- 풀스택프레임워크
- 자바독학
- 빅데이터
- 자바정리
- 자바
- 코스닥
- SNS
- 코딩
- java정리
- 개인프로젝트
- 코딩테스트
- 주가예측
- 개발자
- 프로그램
Archives
- Today
- Total
Creative Code
EX03_binary_led_interrupt -(1) (버튼누를 때마다 다음 이진수 led출력) 본문
const int led[6] = {8,9,10,11,12,13};
const int SW_0 = 2;
const int SW_1 = 3;
int cnt =0;
void SW0_Pressed(void) {
for (int i = 0; i<6; i++) {
digitalWrite(led[i],cnt&(0x01 << i) ? HIGH : LOW);
}
cnt++;
}
void setup() {
// put your setup code here, to run once:
for (int i = 0; i<6; i++) {
pinMode(led[i],OUTPUT);
}
attachInterrupt(digitalPinToInterrupt(SW_0),SW0_Pressed,RISING); //0에서 1로 바뀔때 SW0_Pressed 함수를 수행
//attachInterrupt 를 사용하면 loop문을 안돌아도 내부 칩에서 자체적으로 명령을 수행한다.
}
void loop() {
// put your main code here, to run repeatedly:
}
'Arduino(C,C++)' 카테고리의 다른 글
EX03_binary_led_interrupt -(2) (2,3번핀이 아닌 다른핀에 버튼을 연결할때) (0) | 2023.08.11 |
---|---|
06_SW_INPUT_interrupt(스위치누를때마다 led on/off) (0) | 2023.08.11 |
05_SW_INPUT (0) | 2023.08.10 |
04_Serial_Read (0) | 2023.08.10 |
EX02_DC_MOTOR (0) | 2023.08.10 |