RC Software


By Prof. Seungchul Lee
http://iai.postech.ac.kr/
Industrial AI Lab at POSTECH

  • Please submit the following files after today's class.
    • arduino files
    • Demonstration videos of your RC car
  • TA's E-mail : juwonna7@postech.ac.kr
    • The title of your mail should be "[MECH199-01][Drone & RC Car] (Group Name) WEEK8"

Table of Contents

1. Let's move out

1.1 Drive Motor

Let's drive motors you assembled last class.
In this class, each two motors on left and right drive together.

  • First, set pinMode for each pin of motor drive from datasheet


  • Fill arduino code below.
// arduino code
int PIN_STNB = 3
int PIN_AIN1 = 4
int PIN_AIN2 = 5
int PIN_PWMA = 6
// and so on
void setup(){
    pinMode(PIN_STNB, OUTPUT);
    pinMode(PIN_AIN1, OUTPUT);
    pinMode(PIN_AIN2, OUTPUT);
    pinMode(PIN_PWMA, OUTPUT);
    // and so on
}
  • Drive motors with proper digitalWrite functions.
void loop(){
    digitalWrite(PIN_STNB, HIGH);
    digitalWrite(PIN_AIN1, HIGH);
    digitalWrite(PIN_AIN2, LOW);
    analogWrite(PIN_PWMA, 255);
    // and so on
}

1.2. Change Speed and Direction

  • Try the speed and steering control of the RC car with your own code.
  • Add analogWrite function on your code.

2. Modulization

2.1. Create Functions

Create functions for 8-way move. LEFT and RIGHT be replaced with TURNCW and TURNCCW. Each functions should have parameters to adjust speed or direction(how much rotate).

void FORWARD(int speed){
  digitalWrite( , );
  digitalWrite( , );
  analogWrite( , speed);
  // fill your code
}
void FORWARD_LEFT(int speed, int direction){
  digitalWrite( , );
  digitalWrite( , );
  analogWrite( , speed);
  // fill your code
}

or you can use speed of left / right motors as parameter of FORWARD_LEFT

void FORWARD_LEFT(int left_spd, int right_spd){
  digitalWrite( , );
  digitalWrite( , );
  analogWrite( , speed);
  // fill your code
}

3. Make your scenarios

Make sequence of motions with function you made.
delay(milliseconds); function of ArduinoIDE may be useful.

void loop(){
    FORWARD(150); // first motion
    delay(1000);
FORWARD_LEFT(100, 45); // second motion
    delay(1000);
    // fill your code
}

3.1. Add LED Function

Should a car tail lights up when turn?

  • Write your code for LEDs with your own logic.
In [1]:
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')