How would one code this IR sequence for the arduino?

 How do you code this sequence for the arduino assuming the IR LED is attached to pin 2. 
The first code on the page...

www.alanmacek.com/nikon/


sort by: active | newest | oldest
Jayefuu7 years ago
Scrap my last comment... I just remembered I started writing and ible on it but never got around to publishing it or taking pictures. I lost the code from my computer but I'd uploaded it to my ible. It should just work. Enjoy!

https://www.instructables.com/id/E7OY9ADG0KQLHUE/
Jayefuu7 years ago
I did similar for my housemate's D40 but can't find the code... it went something like this. I'm not doing it all for you though, you'll need to find some code to check for button presses and you need to fill out the function on().

int ledPin = 2;    // select the input pin for the potentiometer

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT); 
  digitalWrite(ledPin,LOW);
  int i=0;
}

void loop() {


 on(2250us);  //(40khz modulated) off(27600); //(no signal) on(650us); off(1375); on(575us); off(3350) on(650) delay(63); //-- repeated a second time after 63ms  on(2250us);  //(40khz modulated) off(27600); //(no signal) on(650us); off(1375); on(575us); off(3350) on(650) }  void on(int time){   digitalWrite(ledPin,HIGH);   //period of a 40kHz modulated signal is 1/40000 = 25 microseconds   //divide the time do be on for by 25 then iterate through that amount with it on for 13 and off for 12 micro at a time until you hit the time/25 }  void off(int time){   digitalWrite(ledPin,LOW);   delayMicroseconds(time); } 
Jayefuu Jayefuu7 years ago
interesting.... instructables messed up the code I wrote.
Jayefuu Jayefuu7 years ago
 int ledPin = 2;    // select the input pin for the potentiometer int i=0;  void setup() {    // declare the ledPin as an OUTPUT:    pinMode(ledPin, OUTPUT);      digitalWrite(ledPin,LOW);      }   void loop() {   on(2250);  //(40khz modulated)    off(27600); //(no signal)    on(650us);    off(1375);    on(575);    off(3350);    on(650);   digitalWrite(ledPin,LOW);    delay(63); //-- repeated a second time after 63ms     on(2250);  //(40khz modulated)    off(27600); //(no signal)    on(650us);    off(1375);    on(575);    off(3350)    on(650)  }    void on(int time){  digitalWrite(ledPin,HIGH);   //period of a 40kHz modulated signal is 1/40000 = 25 microseconds   //divide the time do be on for by 25 then iterate through that amount with it on for 13 and off for 12 micro at a time until you hit the time/25  }    void off(int time){ digitalWrite(ledPin,LOW); delayMicroseconds(time);  }
Jayefuu Jayefuu7 years ago
Grrrr it messed up the line breaks again.

Here... have a text file. Don't expect it to compile or be right, but it should help you out a bit.

Bug submitted.
The line breaks have been broken in <PRE> code since the new CKEditor was deployed.  Unfortunately, the editor internals are not something I'bles can (or wants to!) fix themselves (doing that with the previous editor got them into a downward spiral of endless bugs, fixes and mods).

The only stupid and tedious solution I've found is to do each line individually.  You can mark it as "typewriter" style (or use <Code> tags via Source).  For example:

#include <iostream>
int main() {
  for (int i=0; i<50; i++) {
    std::cout << "Hello, World!" << std::endl;
  }
}


The otherwise identical code, using the correct HTML (<PRE> block) comes out:
 #include <iostream> int main() {   for (int i=0; i<50; i++) {     std::cout << "Hello, World!" << std::endl;   } }
Argh.
Thanks Mike. I've learnt to copy everything to my clipboard before posting now. Saves me rewriting when things go wrong :p
seandogue7 years ago
ypou know what...you really need to parse that query down to something that is relatively directly answerable, instead of posting a link to someone's entire project and expecting us to read it all the way thru and translate it for you...I mean...come on dude. get real. Has the culture of privilege and servitude really gotten this bad?