Wednesday, October 10, 2012

IR-PD to Arduino Project

IR-PD to Arduino

You can build any project with infrared application base.
Now simple connection to activate infrared sensor module on arduino

Source code:

/* infrared-photodiode code
john instrument 2012 */

const int infraPin = 12;     // the number of the Infrared-Photodiode output pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int infraState = 0;         // variable for reading the infra output status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);     
  // initialize the infra output pin as an input on arduino board:
  pinMode(infraPin, INPUT);    
}

void loop(){
  // read the state of the infra output value:
  infraState = digitalRead(infraPin);

  // check if the infra output is active.
  // if it is, the infra outputState is HIGH:
  if (infraState == HIGH) {    
    // turn LED on:   
    digitalWrite(ledPin, HIGH);
    delay(100);
    digitalWrite(ledPin, LOW);
    delay(100);
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, HIGH);
    //on digital output pins, you can use any output device, like buzzer or anythings
   
  }
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Schematic configuration pin, you can see below