Page 981 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 981
void MC(int direction){//모터 C 동작
if(direction == 1){//순방향
GPIO_SetBits(GPIOB,GPIO_Pin_4);
GPIO_ResetBits(GPIOB,GPIO_Pin_5);
}
else{//역방향
GPIO_SetBits(GPIOB,GPIO_Pin_5);
GPIO_ResetBits(GPIOB,GPIO_Pin_4);
}
}
void MS(){//모든 모터 멈춤
MSA();
MSB();
MSC();
}
void TURN_R(){//우로 회전
MA(1);
MB(1);
MC(1);
}
void TURN_L(){//좌로 회전
MA(0);
MB(0);
MC(0);
}
위의 프로그램은 Open CV를 사용하는 쓰레기 추적 프로그램이다. 컨트롤러로 조종하는 소스
는 비슷하나 조금 다른점이 있어 추가한다.
#include "stm32f10x.h"
#include "stm32f10x_conf.h"
#include "USART.h"
void Init_All_Periph(void);
void NVIC_Configuration(void);
void RCC_Configuration(void);
- 974 -