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
- 코테
- 프로그램
- 자바
- 코딩독학
- 코딩
- 프로그래밍
- 코딩테스트
- 사물인터넷
- 주가예측
- backend
- C++
- SNS
- 프로그래머스
- 자바독학
- frontend
- 개인프로젝트
- 개발
- 빅데이터
- 백준
- 풀스택프레임워크
- 자바정리
- Python
- 모의 주식
- java정리
- Project
- 이웃한 칸
- 코스닥
- Reflex
- 개발자
- java
Archives
- Today
- Total
Creative Code
EX02_DC_MOTOR 본문
#define STOP 0
#define CW 1
#define CCW 2
const int DC_P = 5;
const int DC_N = 4;
const int DC_E = 3;
//사용자 함수 선언
void DC_MOTOR_cnt1(int mode, int time);
void setup() {
// put your setup code here, to run once:
pinMode(DC_P,OUTPUT);
pinMode(DC_N,OUTPUT);
pinMode(DC_E,OUTPUT);
DC_MOTOR_cnt1(CW,1000); // 시계방향으로 1초동안 회전
DC_MOTOR_cnt1(STOP,3000); // 3초동안 정지
DC_MOTOR_cnt1(CCW,1000); // 반시계방향으로 1초동안 회전
DC_MOTOR_cnt1(STOP,3000);
}
void loop() {
// put your main code here, to run repeatedly:
}
//사용자 함수 구현
void DC_MOTOR_cnt1(int mode, int time) {
if (mode == STOP) {
digitalWrite(DC_E,LOW);
digitalWrite(DC_P,LOW);
digitalWrite(DC_N,LOW);
} else if (mode == CW) {
digitalWrite(DC_E,HIGH);
digitalWrite(DC_P,HIGH);
digitalWrite(DC_N,LOW);
} else {
digitalWrite(DC_E,HIGH);
digitalWrite(DC_P,LOW);
digitalWrite(DC_N,HIGH);
}
delay(time);
}
'Arduino(C,C++)' 카테고리의 다른 글
05_SW_INPUT (0) | 2023.08.10 |
---|---|
04_Serial_Read (0) | 2023.08.10 |
02_LED_ON_OFF-(3) (0) | 2023.08.10 |
02_LDE_ON_OFF -(2) (0) | 2023.08.10 |
01_Serial_print.ino (0) | 2023.08.10 |