User Tools

Site Tools


tutorials:learn:sensors:ir.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:learn:sensors:ir.html [2010/10/07 20:16]
daigo
tutorials:learn:sensors:ir.html [2016/01/28 18:05] (current)
Line 1: Line 1:
 ====  ==== ====  ====
-[[http://​www.ladyada.net/​learn/​../​make/​logshield/​Documents/​ladyada_net-www/​ladyada_net-www/​images/​sensors/​pna4602.jpg|{{ http://​www.ladyada.net/​images/​sensors/​pna4602_t.jpg?​nolink&​500x385 |}}]] +[[http://​www.ladyada.net/​images/​sensors/​pna4602.jpg|{{ http://​www.ladyada.net/​images/​sensors/​pna4602_t.jpg?​nolink&​500x385 |}}]] 
 ==== What is an IR detection sensor? ​ ==== ==== What is an IR detection sensor? ​ ====
  
Line 8: Line 8:
  
  
-There are a few difference between these and say a [[cds.html|CdS Photocells]]:​ \\ +There are a few difference between these and say a [[http://​www.ladyada.net/​learn/​sensors/​cds.html|CdS Photocells]]:​ \\ 
  
  
Line 18: Line 18:
  
  
-  *[[#test|Test your IR sensor to make sure its working]] +  *[[#testing_your_ir_detector|Test your IR sensor to make sure its working]] 
-  *[[#rawir|Read raw IR codes into a microcontroller]] +  *[[#ir_remote_signals|Read raw IR codes into a microcontroller]] 
-  *[[#intervalometer|Create a camera intervalometer]] +  *[[#making_an_intervalometer|Create a camera intervalometer]] 
-  *[[#ircommand|Listen for '​commands'​ from a remote control on your microcontroller]] ​+  *[[#reading_ir_commands|Listen for '​commands'​ from a remote control on your microcontroller]] ​ 
 ==== Some stats  ==== ==== Some stats  ====
  
Line 149: Line 150:
 {{  http://​www.ladyada.net/​images/​sensors/​arduinopna4602.gif?​nolink&​618x416 ​ |}} {{  http://​www.ladyada.net/​images/​sensors/​arduinopna4602.gif?​nolink&​618x416 ​ |}}
  
-The good news is that it is very easy to hook up this sensor. ​ Just connect the output to a digital pin. The bad news is that the Arduino'​s friendly **digitalRead()** procedure is a tad too slow to reliably read the fast signal as its coming in. Thus we use the hardware pin reading function directly from pin D2, thats what the line IRpin_PIN & (1 << ​IRpin)does. ​+The good news is that it is very easy to hook up this sensor. ​ Just connect the output to a digital pin. The bad news is that the Arduino'​s friendly **digitalRead()** procedure is a tad too slow to reliably read the fast signal as its coming in. Thus we use the hardware pin reading function directly from pin D2, thats what the line "IRpin_PIN & BV(IRpin))" ​does. 
  
 [[http://​github.com/​adafruit/​Raw-IR-decoder-for-Arduino|You can also get the latest version of this code on github]]<​code C> [[http://​github.com/​adafruit/​Raw-IR-decoder-for-Arduino|You can also get the latest version of this code on github]]<​code C>
Line 197: Line 198:
   ​   ​
 //  while (digitalRead(IRpin)) { // this is too slow! //  while (digitalRead(IRpin)) { // this is too slow!
-    while (IRpin_PIN & (1 << ​IRpin)) {+    while (IRpin_PIN & _BV(IRpin)) {
      // pin is still HIGH      // pin is still HIGH
  
Line 277: Line 278:
  
  
-OK step one is easy, point the remote control at the IR sensor and press the button, we got the following for our ML-L3 Canon remote+OK step one is easy, point the remote control at the IR sensor and press the button, we got the following for our ML-L3 Nikon remote
  
 {{  http://​www.ladyada.net/​images/​sensors/​canonirread.gif?​nolink&​385x307 ​ |}} {{  http://​www.ladyada.net/​images/​sensors/​canonirread.gif?​nolink&​385x307 ​ |}}
Line 319: Line 320:
  
 <code C> <code C>
-// This sketch will send out a canon D50 trigger signal (probably works with most canons)+// This sketch will send out a Nikon D50 trigger signal (probably works with most Nikons)
 // See the full tutorial at http://​www.ladyada.net/​learn/​sensors/​ir.html // See the full tutorial at http://​www.ladyada.net/​learn/​sensors/​ir.html
 // this code is public domain, please enjoy! // this code is public domain, please enjoy!
Line 338: Line 339:
   Serial.println("​Sending IR signal"​);​   Serial.println("​Sending IR signal"​);​
   ​   ​
-  ​SendCanonCode();+  ​SendNikonCode();
  
   delay(60*1000); ​ // wait one minute (60 seconds * 1000 milliseconds)   delay(60*1000); ​ // wait one minute (60 seconds * 1000 milliseconds)
Line 364: Line 365:
 } }
  
-void SendCanonCode() { +void SendNikonCode() { 
-  // This is the code for my particular ​Canon, for others use the tutorial+  // This is the code for my particular ​Nikon, for others use the tutorial
   // to '​grab'​ the proper code from the remote   // to '​grab'​ the proper code from the remote
   ​   ​
Line 393: Line 394:
  
  
-If you look at     SendCanonCode() you will see the IR command code that we deduced in the previous project by timing the pulses from the IR sensor. ​+If you look at     SendNikonCode() you will see the IR command code that we deduced in the previous project by timing the pulses from the IR sensor. ​
  
 [[http://​www.ladyada.net/​images/​sensors/​intervalometer.jpg|{{ ​ http://​www.ladyada.net/​images/​sensors/​intervalometer_t.jpg?​nolink&​500x463 ​ |}}]] [[http://​www.ladyada.net/​images/​sensors/​intervalometer.jpg|{{ ​ http://​www.ladyada.net/​images/​sensors/​intervalometer_t.jpg?​nolink&​500x463 ​ |}}]]
/home/ladyada/public_html/wiki/data/attic/tutorials/learn/sensors/ir.html.1286482606.txt.gz · Last modified: 2016/01/28 18:05 (external edit)