김진욱gledel
Published © GPL3+

RC Car Making and Control

This project focuses on RC car making and control.

IntermediateShowcase (no instructions)2 hours560
RC Car Making and Control

Story

Read more

Schematics

schematic

Code

RCCAR code

Arduino
// 모터B의 핀배열 
#define B1A 5// motor B 속도조절
#define B1B 6// motor B 방향조절

// 모터A의 핀배열
#define A1A 9  // motor A 속도조절
#define A1B 10 // motor A 방향조절

int carSpeed = 200; // RC카의 속도

void setup() {
  Serial.begin(9600);    // 시리얼 통신 초기화(0번:RX, 1번:TX로 사용), 하드웨어 시리얼 포트로 블루투스와 통신

  pinMode(A1A, OUTPUT);
  pinMode(A1B, OUTPUT);
  pinMode(B1A, OUTPUT);
  pinMode(B1B, OUTPUT);
}

void loop() {

  if (Serial.available()) {
    
    char command = Serial.read(); // 블루투스로 수신된 명령어를 command에 저장
    
    if (command == 'F' || command == 'f') {
      // F 또는 f를 입력으로 받는 경우 RC카를 전진시키는 함수 호출
      moving_forward();
    }
    else if (command == 'B' || command == 'b') {
      // B 또는 b를 입력으로 받는 경우 RC카를 후진시키는 함수 호출
      moving_backward();
    }
    else if (command == 'L' || command == 'l') {
      // L 또는 l을 입력으로 받는 경우 RC카를 왼쪽으로 회전시키는 함수 호출
      moving_left();
    }
    else if (command == 'R' || command == 'r') {
      // R 또는 r을 입력으로 받는 경우 RC카를 오른쪽으로 회전시키는 함수 호출
      moving_right();
    }
    else if (command == 'S' || command == 's') {
      // S 또는 s를 입력으로 받는 경우 RC카를 정지시키는 함수 호출
      stop_moving();
    }
    else {
      // 인식하지 못하는 명령어 수신시 RC카를 정지시키는 함수 호출
      stop_moving();
    }
    
  }

  // 일정시간 지연
  delay(100);
}

void moving_forward() {
  // 모터A를 정방향으로 회전
  digitalWrite(A1B, HIGH);

Credits

김진욱

김진욱

7 projects • 1 follower
highschool student learning 3D Priinting in Fab Lab
gledel

gledel

100 projects • 115 followers
Looking back on my childhood, I was happy when I was making something and I was proud of myself. "Making is instinct!"

Comments