Wednesday, October 28, 2015

Robot Controlled by a TV Remote

Peanutz : My Robotic Dog







ARDUINO SKETCH:

/* ===============================================================
      Project Homotronics: Robot controlled by a TV remote
      Author: J. B. Wylzan with some help from the Arduino community
      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();  
  }

}



PEANUTZ


Disclaimer:  We shall not be liable for any loss or damage of whatever nature - direct, indirect, consequential, or otherwise - which may arise as a result of your use of any information on this website. However, if you are interested in using any of the projects for personal or educational purposes, please inform the author by email. 

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


"The Last Human on Earth will no longer be Human." ~ Joey Lawsin
================================================================== 
The Homotronics® and Homodruinos® logos are registered trademarks.
Copyright Biotronics© Inc. iHackRobot®. All Rights Reserved.
Patent Pending. 2000 © ®


 ================================================================== 







No comments:

Post a Comment