Advertisement
nnvt

V2

Aug 14th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. // This sketch will send out a Nikon D50 trigger signal (probably works with most Nikons)
  2. // See the full tutorial at http://www.ladyada.net/learn/sensors/ir.html
  3. // this code is public domain, please enjoy!
  4.  
  5. int IRledPin = 9; // LED connected to digital pin 13
  6. int inPin = 5;
  7. int val = 0;
  8.  
  9. // The setup() method runs once, when the sketch starts
  10.  
  11. void setup() {
  12. // initialize the IR digital pin as an output:
  13. pinMode(IRledPin, OUTPUT);
  14. pinMode(inPin, INPUT);
  15.  
  16. Serial.begin(9600);
  17. }
  18.  
  19. void loop()
  20. {
  21. val = digitalRead(inPin);
  22. Serial.println("Sending IR signal");
  23.  
  24. SendChannelUpCode();
  25.  
  26.  
  27.  
  28.  
  29. }
  30.  
  31. // This procedure sends a 38KHz pulse to the IRledPin
  32. // for a certain # of microseconds. We'll use this whenever we need to send codes
  33. void pulseIR(long microsecs) {
  34. // we'll count down from the number of microseconds we are told to wait
  35.  
  36. cli(); // this turns off any background interrupts
  37.  
  38.  
  39. if (val == HIGH) {
  40. // 38 kHz is about 13 microseconds high and 13 microseconds low
  41. digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
  42. delayMicroseconds(10); // hang out for 10 microseconds
  43. digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
  44. delayMicroseconds(10); // hang out for 10 microseconds
  45.  
  46. // so 26 microseconds altogether
  47. microsecs -= 26;
  48. }
  49.  
  50. sei(); // this turns them back on
  51. }
  52.  
  53. void SendChannelUpCode() {
  54. // This is the code for the CHANNEL + for the downstairs TV COMCAST
  55. delayMicroseconds(60696); //Time off (Left Column on serial monitor)
  56. pulseIR(4740); //Time on (Right Column on serial monitor)
  57. delayMicroseconds(4160);
  58. pulseIR(820);
  59. delayMicroseconds(1400);
  60. pulseIR(820);
  61. delayMicroseconds(1380);
  62. pulseIR(800);
  63. delayMicroseconds(1420);
  64. pulseIR(780);
  65. delayMicroseconds(300);
  66. pulseIR(760);
  67. delayMicroseconds(360);
  68. pulseIR(760);
  69. delayMicroseconds(340);
  70. pulseIR(760);
  71. delayMicroseconds(340);
  72. pulseIR(760);
  73. delayMicroseconds(340);
  74. pulseIR(760);
  75. delayMicroseconds(1440);
  76. pulseIR(760);
  77. delayMicroseconds(1460);
  78. pulseIR(740);
  79. delayMicroseconds(1480);
  80. pulseIR(720);
  81. delayMicroseconds(380);
  82. pulseIR(680);
  83. delayMicroseconds(420);
  84. pulseIR(660);
  85. delayMicroseconds(460);
  86. pulseIR(640);
  87. delayMicroseconds(460);
  88. pulseIR(620);
  89. delayMicroseconds(500);
  90. pulseIR(600);
  91. delayMicroseconds(500);
  92. pulseIR(600);
  93. delayMicroseconds(1600);
  94. pulseIR(600);
  95. delayMicroseconds(500);
  96. pulseIR(600);
  97. delayMicroseconds(500);
  98. pulseIR(580);
  99. delayMicroseconds(520);
  100. pulseIR(580);
  101. delayMicroseconds(520);
  102. pulseIR(560);
  103. delayMicroseconds(540);
  104. pulseIR(560);
  105. delayMicroseconds(560);
  106. pulseIR(540);
  107. delayMicroseconds(1660);
  108. pulseIR(540);
  109. delayMicroseconds(560);
  110. pulseIR(540);
  111. delayMicroseconds(1680);
  112. pulseIR(520);
  113. delayMicroseconds(1680);
  114. pulseIR(540);
  115. delayMicroseconds(1660);
  116. pulseIR(540);
  117. delayMicroseconds(1680);
  118. pulseIR(540);
  119. delayMicroseconds(1660);
  120. pulseIR(540);
  121. delayMicroseconds(1660);
  122. pulseIR(540);
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement