Robotics
This page will soon hold some of my robotics projects.
IR Decode
Below is code for an IR Decoder. More information will be added shortly.
// ************************************** // IR Decoder Program Using Javelin Stamp // By:Jon Keinath // www.jonkeinath.com // jonkeinath@gmail.com // // Last Update: 6.20.2005 //*************************************** import stamp.core.*; public class IRDecode { // ----------Class Variables---------- private int start,p1,p2,p3,p4,p5,p6 = 0; //each pulse measurement private int value = 0; //returned value of button pushed private int pin; //pin that IR Receier is on // ----------Constructors---------- public IRDecode(int inPin) { pin = inPin; } // ----------Methods------------ public int getValue() { //If a start pulse is detected it then gathers the following key //code and returns it as a decimal number other wise it returns 0 //(for a tighter loop p6 can be removed if you are not using any //"fancy" buttons on the remote.) value = 0; //make sure value is zero(0) start = CPU.pulseIn(6000,pin,false); //check for start pulse if (start > 250 && start < 400) //if start pulse received { p1 = CPU.pulseIn(200,pin,false); p2 = CPU.pulseIn(200,pin,false); p3 = CPU.pulseIn(200,pin,false); p4 = CPU.pulseIn(200,pin,false); p5 = CPU.pulseIn(200,pin,false); p6 = CPU.pulseIn(200,pin,false); if (p1>100) value=value+1; if (p2>100) value=value+2; if (p3>100) value=value+4; if (p4>100) value=value+8; if (p5>100) value=value+16; if (p6>100) value=value+32; value++; } return value; } }