2016年6月27日 星期一

紅外線接收模組

如果使用的是紅外線接收模組,規格參考如下:

  • Supply Voltage: 2.7V to 5.5V
  • Supply Current : 1.5mA
  • Operating Temperature: -25°C to 85°C
  • Frequency: 37.9KHZ
  • Receiving Angle: 90°
  • Receiving Distance: 18m
接腳為:
  • - 或 G : GND
  • S 或 Y : Signal
  • 剩下的接腳 : VCC
如果是這個:

程式碼如下:

#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
delay(200);
}

沒有留言:

張貼留言