Created
February 7, 2012 13:11
-
-
Save sukedai/1759605 to your computer and use it in GitHub Desktop.
Toshiba TV(REGZA serise) IR remote controller sketch for SUWANO Startup Set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Toshiba TV(REGZA serise) IR remote controller sketch for SUWANO Startup Set | |
// | |
// 使い方: | |
// (0) SUWANOスタートアップシールドのLED4を赤外線LEDに付け替えます | |
// (1) Arduino-0023を用意します。1.0だと動きません; | |
// (2) Arduino-0023にIRremoteライブラリをインストール | |
// (3) IRremoteライブラリに次のパッチをあてます -> https://gist.github.com/1759596 | |
// (4) スケッチをコンパイル後、SUWANOに書き込みます | |
// (5) ボタンに次の機能をアサインしています | |
// ボタン1 : ボリュームを上げる | |
// ボタン2 : ボリュームを下げる | |
// ボタン3 : チャンネル1を選択 | |
// ボタン4 : 電源ON/OFF | |
// | |
#include <IRremote.h> | |
IRsend irsend; | |
#define CODE_ON 0x2FD48B7 | |
#define CODE_CH_NEXT 0x2FDD827 | |
#define CODE_CH_PREV 0x2FDF807 | |
#define CODE_VOL_UP 0x2FD58A7 | |
#define CODE_VOL_DOWN 0x2FD7887 | |
#define CODE_SOURCE_CHANGE 0x2FDF00F | |
#define CODE_CH_1 0x2FD807F | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(1, INPUT); | |
pinMode(2, INPUT); | |
pinMode(3, INPUT); | |
pinMode(4, INPUT); | |
pinMode(5, OUTPUT); | |
pinMode(6, OUTPUT); | |
pinMode(10, OUTPUT); | |
digitalWrite(5, HIGH); | |
digitalWrite(6, HIGH); | |
digitalWrite(10, HIGH); | |
} | |
void send_ir(unsigned long data) | |
{ | |
digitalWrite(5, LOW); | |
digitalWrite(6, HIGH); | |
digitalWrite(10, HIGH); | |
irsend.sendNEC(data, 32); | |
delay(100); | |
digitalWrite(5, HIGH); | |
digitalWrite(6, LOW); | |
digitalWrite(10, HIGH); | |
delay(100); | |
digitalWrite(5, HIGH); | |
digitalWrite(6, HIGH); | |
digitalWrite(10, LOW); | |
delay(100); | |
digitalWrite(5, HIGH); | |
digitalWrite(6, HIGH); | |
digitalWrite(10, HIGH); | |
delay(500); | |
} | |
void loop() { | |
if (digitalRead(1)==0) { | |
send_ir(CODE_VOL_UP); | |
return; | |
} | |
else if (digitalRead(2)==0) { | |
send_ir(CODE_VOL_DOWN); | |
return; | |
} | |
else if (digitalRead(3)==0) { | |
send_ir(CODE_CH_1); | |
return; | |
} | |
else if (digitalRead(4)==0) { | |
send_ir(CODE_ON); | |
return; | |
} | |
while (Serial.available()>0) { | |
int c = Serial.read(); | |
switch(c) { | |
case 'p': | |
send_ir(CODE_ON); | |
break; | |
case '1': | |
send_ir(CODE_CH_1); | |
break; | |
case 's': | |
send_ir(CODE_SOURCE_CHANGE); | |
break; | |
case 'n': | |
send_ir(CODE_CH_NEXT); | |
break; | |
case 'd': | |
send_ir(CODE_VOL_DOWN); | |
break; | |
case 'u': | |
send_ir(CODE_VOL_UP); | |
break; | |
default: | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment