Tutorial.RobotRemoteControl History

Hide minor edits - Show changes to markup

May 18, 2013, at 08:02 AM by Scott Fitzgerald -
Changed lines 44-158 from:
to:
May 17, 2013, at 01:36 PM by David Cuartielles -
Changed lines 5-6 from:

This example is considered experimental

to:

This example is considered experimental, you will need to install the IR-Remote library by Ken Shirriff on your IDE for it to run, read the code for more information

May 17, 2013, at 09:14 AM by Scott Fitzgerald -
Changed lines 7-8 from:

If you connect a IR remote receiver to the robot, you can control it like controlling your TV set. Take a remote controller, map some buttons to different actions, and you can make it do different things without even touching the robot!

to:

If you connect a IR remote receiver to the robot, you can control it like controlling your TV set. Take a Sony compatible remote controller, map some buttons to different actions, and you can make the robot move around without touching it!

Changed line 14 from:
  • remote control
to:
  • Sony compatible remote control
Changed line 18 from:
  1. Connect the IR sensor with TKD2 on top board, using the cable provided.
to:
  1. Connect the IR sensor to TKD2 on the top board, using the cable provided.
Changed lines 22-23 from:
  1. Press [insert button name here] and the robot will go forward, [btn name] so it goes backwards. [btn name] and it turns left 90 degrees, [btn name] and it turns right.
  2. You can see the signal value and command(if it's recognized) on the LCD.
to:
  1. Press the buttons you've coded to move the robot.
  2. You can see received signals and commands (if recognized) on the LCD.
Changed line 25 from:
  1. Press the buttons on remote control, take down the signal values showing up on LCD.
to:
  1. Press the buttons on remote control and write down the values showing up on LCD.
Changed lines 31-34 from:
  1. Change the values here to the ones you got previously.

to:
  1. Change the values here to the ones you saw on the screen.

May 15, 2013, at 12:57 PM by Scott Fitzgerald -
Added lines 5-6:

This example is considered experimental

Changed lines 45-157 from:

place the actual code in here

to:

/* 08 Remote Control

 *******************
 ***
 ***This example code is in an experimental state.
 ***You are welcome to try this with your robot,
 ***and no harm will come to it. We will provide a
 ***detailed description of an updated version of this
 ***in a future update
 ***
 *******************

 If you connect a IR receiver to the robot, 
 you can control it like you control a TV set. 
 Using a Sony compatiable remote control, 
 map some buttons to different actions. 
 You can make the robot move around without 
 even touching it!

 Circuit: 
 * Arduino Robot
 * Connect the IRreceiver to TDK2
 * Sony compatible remote control

 based on the IRremote library
 by Ken Shirriff
 http://arcfn.com

 created 1 May 2013
 by X. Yang
 modified 12 May 2013
 by D. Cuartielles

 This example is in the public domain
 */

// include the necessary libraries

  1. include <IRremote.h>
  2. include <ArduinoRobot.h>

// Define a few commands from your remote control

  1. define IR_CODE_FORWARD 0x2C9B
  2. define IR_CODE_BACKWARDS 0x6C9B
  3. define IR_CODE_TURN_LEFT 0xD4B8F
  4. define IR_CODE_TURN_RIGHT 0x34B8F

int RECV_PIN = TKD2; // the pin the IR receiver is connected to IRrecv irrecv(RECV_PIN); // an instance of the IR receiver object decode_results results; // container for received IR codes

void setup() {

  // initialize the Robot, SD card, display, and speaker 
  Robot.begin();
  Robot.beginTFT();
  Robot.beginSD();

  // print some text to the screen
  Robot.stroke(0, 0, 0);
  Robot.text("Remote Control code:", 5, 5);
  Robot.text("Command:", 5, 26);
  irrecv.enableIRIn(); // Start the receiver

}

void loop() {

  // if there is an IR command, process it
  if (irrecv.decode(&results)) {
    processResult();
    irrecv.resume(); // resume receiver
  }

}

void processResult() {

  unsigned long res = results.value;
  // print the value to the screen
  Robot.debugPrint(res, 5, 15);

  if(res == IR_CODE_FORWARD || res == IR_CODE_BACKWARDS || res == IR_CODE_TURN_LEFT || res == IR_CODE_TURN_RIGHT) {
    Robot.fill(255, 255, 255);
    Robot.stroke(255, 255, 255);

    Robot.rect(5, 36, 55, 10);
  }
  switch(results.value){
    case IR_CODE_FORWARD:
      Robot.stroke(0, 0, 0);
      Robot.text("Forward", 5, 36);
      Robot.motorsWrite(255, 255);
      delay(300);
      Robot.motorsStop();
      break;
    case IR_CODE_BACKWARDS:
      Robot.stroke(0, 0, 0);
      Robot.text("Backwards", 5, 36);
      Robot.motorsWrite(-255, -255);
      delay(300);
      Robot.motorsStop();
      break;
    case IR_CODE_TURN_LEFT:
      Robot.stroke(0, 0, 0);
      Robot.text("Left", 5, 36);
      Robot.motorsWrite(-255, 255); 
      delay(100);
      Robot.motorsStop();
      break;
    case IR_CODE_TURN_RIGHT:
      Robot.stroke(0, 0, 0);
      Robot.text("Right", 5, 36);
      Robot.motorsWrite(255, -255); 
      delay(100);
      Robot.motorsStop();
      break;
  }

}

May 10, 2013, at 05:43 PM by Xun Yang -
Added lines 15-32:

Instruction

  1. Connect the IR sensor with TKD2 on top board, using the cable provided.
  2. Fix the sensor on the board
  3. Upload the example, unplug USB and turn on power
  4. After the starting screen, use the remote control to send it commands
  5. Press [insert button name here] and the robot will go forward, [btn name] so it goes backwards. [btn name] and it turns left 90 degrees, [btn name] and it turns right.
  6. You can see the signal value and command(if it's recognized) on the LCD.
  7. If you want to customize your commands:
    1. Press the buttons on remote control, take down the signal values showing up on LCD.
    2. Locate these lines in the example code:
      #define IR_CODE_FORWARD 0x2C9B
      #define IR_CODE_BACKWARDS 0x6C9B
      #define IR_CODE_TURN_LEFT 0xD4B8F
      #define IR_CODE_TURN_RIGHT 0x34B8F
    3. Change the values here to the ones you got previously.

May 03, 2013, at 11:36 AM by Xun Yang -
Changed lines 1-2 from:

Examples > Lottie Lemon?

to:

Examples > Robot

May 03, 2013, at 06:46 AM by David Cuartielles -
Added lines 1-35:

Share