Thank you for the answers.
I connected the receiver and everything went awesome.
Now, I want to use the Arduino as a remote control.
I hooked up the IR LED on Pin 13 (it already has an internal resistor, right?) and I am trying to reproduce the code I got from the receiver. The thing is that it ain't working.
long times[] = {0, 0, 2680, 3552, 4068, 4880, 5400, 5768, 6292, 6652, 7176, 7988, 8944, 9316, 9832, 10204, 10720, 11092, 11608, 11976, 12496, 12864, 13388, 13748, 14272, 14636, 15152, 15524, 16040, 16412, 16928, 17300, 17820, 18188, 19152, 19960, 20484, 20848, 21364, 21732, 22248, 22620, 23140, 106432, 109116, 109980, 110504, 111312, 111836, 112196, 112712, 113084, 113604, 114420, 115380, 115744, 116268, 116636, 117156, 117524, 118036, 118408, 118924, 119296, 119812};
int IRpin = 13, i, st;
char c; unsigned long j;
void setup() {
Serial.begin(115200);
Serial.println("<----- Arduino Remote ----->");
pinMode(IRpin, OUTPUT);
}
void loop() {
Serial.println("Waiting for order...");
while (Serial.available() == 0) {}
c = Serial.read(); st = LOW;
Serial.print("Pushed button: ");
Serial.print(c); Serial.println("");
for (i = 1; i < 65; i++) {
digitalWrite(IRpin, st);
j = micros();
while (micros() - j < times[i] - times[i-1]) {}
if (st == LOW && i != 1) st = HIGH;
else st = LOW;
// Serial.print("In the "); Serial.print(i); Serial.print(" iteration\n");
}
digitalWrite(IRpin, LOW);
delay(2000);
}
Is anything wrong in my code?