Translate

Membuat Robot Kendali Remot TV / DVD / VCD (NEC Remote) Menggunakan Arduino

Membuat Robot Kendali Remot TV / DVD / VCD (NEC Remote) Menggunakan Arduino


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana caranya membuat sebuah robot yang dapat dikendalikan menggunakan remote TV / DVD atau NEC. Jadi robot ini seperti halnya remote control bisa dikendalikan arah pergerakannya menggunakan remote. Sensor IR yang dipakai adalah TSOP yang mana merupakan IR Remote TV. untuk lebih jelasnya berikut adalah skema dan programnya. 



a. Arduino Uno





b. Driver Motor L298





c. Motor DC + Gearbox





d. Remote TV / DVD / NEC dan TSOP Sensor






e. Program Arduino IDE

#include "Adafruit_NECremote.h"

// Connect a 38KHz remote control sensor to the pin below
#define IRpin         11

Adafruit_NECremote remote(IRpin);

int mtrkanan1 = 4;
int mtrkanan2 = 5;
int mtrkiri1 = 6;
int mtrkiri2 = 7;

int kecmtr1 = 9;
int kecmtr2 = 10;

void setup(void) {
  Serial.begin(9600);
  Serial.println("Ready to decode IR!");
  pinMode (mtrkanan1, OUTPUT);
  pinMode (mtrkanan2, OUTPUT);
  pinMode (mtrkiri1, OUTPUT);
  pinMode (mtrkiri2, OUTPUT);
  pinMode (kecmtr1, OUTPUT);
  pinMode (kecmtr2, OUTPUT);
}

int lastcode = -1;

void loop(void) {
  // You can set the listen() time out to 'n' seconds
  int c = remote.listen(5);  // seconds to wait before timing out!
  // Or you can wait 'forever' for a valid code
  //int c = remote.listen();  // Without a #, it means wait forever

  if (c >= 0) {
    Serial.print("Received code #");
    Serial.println(c, DEC);
    lastcode = c;
  
  if (c == 70){  
    analogWrite(kecmtr1,250);
  digitalWrite(mtrkanan1, LOW);
  digitalWrite(mtrkanan2, HIGH);
 
  analogWrite(kecmtr2, 250);
  digitalWrite(mtrkiri1, LOW);
  digitalWrite(mtrkiri2, HIGH);
 
}

  if (c == 21){  
  analogWrite(kecmtr1,250);
  digitalWrite(mtrkanan1, HIGH);
  digitalWrite(mtrkanan2, LOW);
 
  analogWrite(kecmtr2, 250);
  digitalWrite(mtrkiri1, HIGH);
  digitalWrite(mtrkiri2, LOW);
  } 
 
  if (c == 64){
    analogWrite(kecmtr1,250);
  digitalWrite(mtrkanan1, LOW);
  digitalWrite(mtrkanan2, LOW);
 
  analogWrite(kecmtr2, 250);
  digitalWrite(mtrkiri1, LOW);
  digitalWrite(mtrkiri2, LOW);
  }
 
  if (c == 67){
    analogWrite(kecmtr1,250);
  digitalWrite(mtrkanan1, LOW);
  digitalWrite(mtrkanan2, HIGH);
 
  analogWrite(kecmtr2, 250);
  digitalWrite(mtrkiri1, LOW);
  digitalWrite(mtrkiri2, LOW);
  }
 
  if (c == 68){
    analogWrite(kecmtr1,250);
  digitalWrite(mtrkanan1, LOW);
  digitalWrite(mtrkanan2, LOW);
 
  analogWrite(kecmtr2, 250);
  digitalWrite(mtrkiri1, LOW);
  digitalWrite(mtrkiri2, HIGH);
  }
 
  } else if (c == -3) {
    Serial.print("Repeat (");
    Serial.print(lastcode);
    Serial.println(")");
  } else if (c == -2) {
    Serial.println("Data error");
  } else {
    Serial.println("Timed out waiting!");
  }
}





f. VIDEO HASILNYA








No comments:

Post a Comment