Tuesday, November 24, 2015

TV Remote Control Experiment









ARDUINO SKETCH:

/* ===============================================================
      Project Homotronics: Robot controlled by a TV remote
      Author: J. B. Wylzan with libraries from the Arduino website
      Website: http://www.iHackRobot.blogspot.com
      Abstract: Control a robot via a TV remote control.
================================================================== */

#include <IRremote.h>

const int MLWF = 10;         
const int MLBB = 9;
const int MRYF = 6;         
const int MRRB = 5;

// The codes below were generated from our Project the Infra Red Sensor.
const long lft = 0x4EB338C7;    
const long fwd = 0x4EB322DD;    
const long rht = 0x4EB312ED;    
const long rvs = 0x4EB3B847;    
const long stp = 0x4EB33AC5;    

IRrecv irrecv(IR_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();        // turn on the receiver
  pinMode(MLWF, OUTPUT);
  pinMode(MLBB, OUTPUT);
  pinMode(MRYF, OUTPUT);
  pinMode(MRRB, OUTPUT);}

void loop() {
  if (irrecv.decode(&results)) {
    long int decCode = results.value;
    Serial.println(decCode);
    
    switch (results.value) {
      case lft:
        Serial.println("Left");
       analogWrite(MLBB, 0);     
    analogWrite(MLWF, 255);
    analogWrite(MRRB, 0);     
    analogWrite(MRYF, 0);   
        break;
        
      case fwd:
        Serial.println("Forward");
        analogWrite(MLBB, 0);     
    analogWrite(MLWF, 255);
    analogWrite(MRRB, 0);     
    analogWrite(MRYF, 255);          break;
        
      case rht:
        Serial.println("Right");
         analogWrite(MLBB, 0);     
    analogWrite(MLWF, 0);
    analogWrite(MRRB, 0);     
    analogWrite(MRYF, 255);  
        break;
        
      case rvs:
        Serial.println("Reverse");
         analogWrite(MLBB, 255);     
    analogWrite(MLWF, 0);
    analogWrite(MRRB, 255);     
    analogWrite(MRYF, 0);        break;  
        
      case stp:
        Serial.println("Stop");
        analogWrite(MLBB, 0);     
    analogWrite(MLWF, 0);
    analogWrite(MRRB, 0);     
    analogWrite(MRYF, 0); 
        break;  
        
      default: 
        Serial.println("Press a key ...");
    }
    irrecv.resume();  
  }
}

/* ================================================================== */





 ==================================================================
"Humans can't think of something, without associating it with something."
 ~ Joey Lawsin
==================================================================

NOTICE: Articles on this site are composed on random thoughts. The transcript may not be in its final form. It maybe edited, updated or even revised in the future based on the outcomes of  the author's experiments.

Public Domain Notice: Copyright (c) 2000. All rights reserved. This article is part of a book entitled Biotronics: The Silver Species. Copies are welcome to be shared or distributed publicly as long proper citations are observed. Please cite as follows: The Biotronics Project, Joey Lawsin, 1988, USA.

================================================================== 
The Homotronics® and Homodruinos® logos are registered trademarks.
Copyright Biotronics© Inc. iHackRobot®. All Rights Reserved.
Patent Pending. 2000 © ®
 ==================================================================



No comments:

Post a Comment