wau2380's playground

[모각코 아두이노] 15일차 / RC카 후기 본문

모각코/아두이노

[모각코 아두이노] 15일차 / RC카 후기

wau2380 2021. 10. 2. 00:18

프로젝트 이름 : 스마트 RC카

프로젝트 소개 및 설명 : RC카를 아두이노로 제작, RC카를 스마트폰으로 조종하려고 했으나  시간이 안되서

움직이만 구현함

회로 구성 설명 (사진 포함)

코드 설명 (코드 포함)

int RightMotor_E_pin = 5;      // 오른쪽 모터의 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
int LeftMotor_E_pin = 6;      // 왼쪽 모터의 Enable & PWM

void SmartCar_Go();
void SmartCar_Back();


int E_carSpeed = 153; // 최대 속도의  60 %

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);
}

void loop() {
  SmartCar_Go();
  delay(3000);
  SmartCar_Back();
  delay(3000);
}


void SmartCar_Go() {       // 전진
  Serial.println("Forward");
  digitalWrite(RightMotor_1_pin, HIGH);
  digitalWrite(RightMotor_2_pin, LOW);
  digitalWrite(LeftMotor_3_pin, HIGH);
  digitalWrite(LeftMotor_4_pin, LOW);

  for (int i = 0; i <= E_carSpeed; i = i + 5) {
    analogWrite(RightMotor_E_pin, i);     
    analogWrite(LeftMotor_E_pin, i);
    delay(20);
  }
}

void SmartCar_Back() {       // 후진
  Serial.println("Backward");
  digitalWrite(RightMotor_1_pin, LOW);
  digitalWrite(RightMotor_2_pin, HIGH);
  digitalWrite(LeftMotor_3_pin, LOW);
  digitalWrite(LeftMotor_4_pin, HIGH);

  for (int i = 0; i <= E_carSpeed; i = i + 5) {
    analogWrite(RightMotor_E_pin, i);     
    analogWrite(LeftMotor_E_pin, i);
    delay(20);
  }
}

문제점 & 어떻게 문제를 해결했나요?

그.. 나사를 조이는데 너무 성급해서 나사구멍이 헐어서 결국 본드로 붙여버렸네요. 

다음부턴 조급해하지 않는 마음을 길러야겠어요.

프로젝트 디자인 소개 (사진 포함)

프로젝트 작동 영상

 

 

너무 재밌었습니다. 아두이노 만드는 동안 인내심을 많이 시험당하긴 했지만

그래도 결과물이 있으니까요.

아무쪼록, 코뮤니티 모각코에 아두이노 많은 지원 부탁드립니다.

게시글 : https://cafe.naver.com/codeuniv/46607

 

[모각코 출석 인증] 5일차 - 아두이노로 배우는 C언어 9월 과정 A조

대한민국 모임의 시작, 네이버 카페

cafe.naver.com

코뮤니티 : https://cafe.naver.com/codeuniv