2011年12月8日 星期四

IRremote 2

940nm紅外線發射器

手邊沒有100ohm電阻用4.7ohm擋著用

/**
 * IRRemote 2
 */
#include 
#include 

#define BtnPin 2
int buttonState = 0;
// IRremote的IR發射器只能裝在pin 3
IRsend irsend;

void setup() {
  pinMode( BtnPin, INPUT );
  Serial.begin( 9600 );
}

void loop() {
  buttonState = digitalRead( BtnPin );
  
  if( buttonState == HIGH ) {
    Serial.println( "GoGoGo" );
    irsend.sendNEC( 0x2FF00FF, 32 );
  }
}
送出去的訊號就是之前用接收器,讀取冷氣機遙控,由IRremote解出來的protocol的來送。
這玩具越玩越想買樂高機器人...@@"

沒有留言:

張貼留言