Task 45:
Here is the code that i am using for the IR sender and receiver on the same Arduino.
const int infraSender = 13;
const int infraReceiver = 2;
int infra;
void setup(){
pinMode(infraReceiver,INPUT);
pinMode(infraSender,OUTPUT);
Serial.begin(9600);
}
void loop()
{
for (int i = 1; i < 21; i ++)
{
digitalWrite(infraSender,HIGH);
infra = digitalRead(infraReceiver);
delay(1000);
if (infra == HIGH)
{
Serial.println(i);
}
else{
Serial.print(i);
Serial.println(" Blocked");
}
Serial.println(infra);
}
Serial.println("Finished");
delay(10000);
}
Thursday, May 13, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment