This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorials:learn:sensors:ir.html [2012/02/11 17:58] ladyada |
tutorials:learn:sensors:ir.html [2016/01/28 18:05] (current) |
||
---|---|---|---|
Line 150: | 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 198: | 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 | ||