Recent Posts
printf("ho_tari\n");
EX02_DC_MOTOR 본문
#define STOP 0
#define CW 1
#define CCW 2
const int DC_E = 3;
const int DC_P = 5;
const int DC_N = 4;
void setup() {
// put your setup code here, to run once:
pinMode(DC_E, OUTPUT);
pinMode(DC_P, OUTPUT);
pinMode(DC_N, OUTPUT);
DC_MOTOR_cntl(CW, 1000);
DC_MOTOR_cntl(STOP, 1000);
DC_MOTOR_cntl(CCW, 1000);
DC_MOTOR_cntl(STOP, 1000);
}
void loop() {
// put your main code here, to run repeatedly:
}
void DC_MOTOR_cntl(int mode, int time)
{
switch(mode){
case STOP:
digitalWrite(DC_E, LOW);
digitalWrite(DC_P, LOW);
digitalWrite(DC_N, LOW);
break;
case CW:
digitalWrite(DC_E, HIGH);
digitalWrite(DC_P, HIGH);
digitalWrite(DC_N, LOW);
break;
case CCW:
digitalWrite(DC_E, HIGH);
digitalWrite(DC_P, LOW);
digitalWrite(DC_N, HIGH);
break;
default:
digitalWrite(DC_E, LOW);
digitalWrite(DC_P, LOW);
digitalWrite(DC_N, LOW);
break;
}
delay(time);
}
'Arduino' 카테고리의 다른 글
<프로젝트> 스마트 주차장 (0) | 2023.09.02 |
---|---|
EX03_Binary_LED_Interrupt (0) | 2023.09.02 |
EX01_Binary_LED (0) | 2023.09.02 |
17_Multi_Task (0) | 2023.09.02 |
16_Keypad_4x4 (0) | 2023.09.02 |