1. serial 모드 에서도 'g','b','s' 입력시 작동 안됨
Recived command : 직진
Recived command : Wrong command
Recived command : 후진
Recived command : Wrong command
Recived command : 정지
Recived command : Wrong command
와 같은 메세지 출력 되어 작동하지 않습니다.
--------------------------------------제공 되어진 code 입니다. 확인 해 주세요-------------------------------------------------------
int RightMotor_E_pin = 5; // 오른쪽 모터의 Enable & PWM
int LeftMotor_E_pin = 6; // 왼쪽 모터의 Enable & PWM
int RightMotor_1_pin = 8; // 오른쪽 모터 제어선 IN1
int RightMotor_2_pin = 9; // 오른쪽 모터 제어선 IN2
int LeftMotor_3_pin = 10; // 왼쪽 모터 제어선 IN3
int LeftMotor_4_pin = 11; // 왼쪽 모터 제어선 IN4
//좌우 모터 속도 조절, 설정 가능 최대 속도 : 255
int L_MotorSpeed = 153; // 왼쪽 모터 속도
int R_MotorSpeed = 153; // 오른쪽 모터 속도
void setup() {
pinMode(RightMotor_E_pin, OUTPUT); // 출력모드로 설정
pinMode(RightMotor_1_pin, OUTPUT);
pinMode(RightMotor_2_pin, OUTPUT);
pinMode(LeftMotor_3_pin, OUTPUT);
pinMode(LeftMotor_4_pin, OUTPUT);
pinMode(LeftMotor_E_pin, OUTPUT);
Serial.begin(9600);
Serial.println("Welcome Eduino!");
}
void loop() {
if (Serial.available()){
char command = Serial.read();
Serial.print("Recived command : ");
if(command == 'g'){
motor_role(HIGH, HIGH);
Serial.println("직진");
}
else if(command == 'b'){
motor_role(LOW, LOW);
Serial.println("후진");
}
else if(command == 's'){
analogWrite(RightMotor_E_pin, 0);
analogWrite(LeftMotor_E_pin, 0);
Serial.println("정지");
}
else{
Serial.println("Wrong command");
}
}
}
void motor_role(int R_motor, int L_motor){
digitalWrite(RightMotor_1_pin, R_motor);
digitalWrite(RightMotor_2_pin, !R_motor);
digitalWrite(LeftMotor_3_pin, L_motor);
digitalWrite(LeftMotor_4_pin, !L_motor);
analogWrite(RightMotor_E_pin, R_MotorSpeed);
analogWrite(LeftMotor_E_pin, L_MotorSpeed);
}
--------------------------------------------------------------------------------------------------------------------------------------------------
2. 모터 드라이버 실습하기
예제 코드 업로드 하였으나 작동 안됨.
3. 리모컨 제어하기
작동 안됨
4. 라인트레이서
상기와 같은 문제로 테스트 하지 못함.
5. 핀 연결 상태 확인 했지만 메뉴얼대로 연결 되어 있음.
6. 코드 이상이라면 parkhwanchul@hotmail.com 으로 새로운 코드 보내 주시면 고맙겠습니다. ( 위에 언급된 모든 코드 확인 해 주세요 )
7. 모터 및 모터 드라이버 PCB 문제 가 의심 된다면 택배(착불)보내 드릴 테니 주소 알려 주십시오.
8. 참고로, 초음파, 서보모터, 라인트레이서센서, 리모컨 작동은 PC에 연결하여 시리얼 모니터로 작동 상태 확인 하였습니다.
댓글목록
작성자 아두
작성일 2022-01-21
평점
시리얼 모니터 설정은 'line ending 없음', '9600 보드레이트'로 설정하시고 테스트 진행해 주시기 바랍니다
모터 제어에는 필수적으로 외부전원을 사용하는데요. 모터 드라이버에서 삐--- 소리가 난다면 전력 부족 혹은 모터 속도가 너무 낮게 설정 되어 돌아가지 않는 것이니 배터리 교체나 모터 속도를 더 올려주세요