Sony Digital Photo Frame DPF-V700 のon/offを送信するスケッチです。
// This is the IR-remote controller signal sender //
// Power on/off Leader+10101000101100111111
// Leader 2.4(high)+0.6(low)=3.0 msec
// 1: 1.2(high)+0.6(low)=1.8 msec、
// 0: 0.6(high)+0.6(low)=1.2 msec
boolean IRsend=LOW; //変数IRsendをboolean(HIGHかLOWの二値)で与える。
unsigned int T1=600; //単位時間
unsigned int T2=1200; //単位時間の2倍 (1の送信用いる)
unsigned int T4=2400; //単位時間の4倍 (Leaderの送信に用いる)
unsigned int T18=10800; // データの最後に加えるoffの長さ。
void setup(){
pinMode(2, OUTPUT); //2番ピンをOUTPUT(出力)に指定。
}
void Leader(){
digitalWrite(2, HIGH); // LEDpin3に5Vを出力。
delayMicroseconds(T4); // 2400usec onのまま。
digitalWrite(2, LOW); // LEDpin8に0Vを出力。
delayMicroseconds(T1); // 600usec offのまま。
}
void One(){
digitalWrite(2, HIGH); // LEDpin3に5Vを出力。
delayMicroseconds(T2); // 1200usec onのまま。
digitalWrite(2, LOW); // LEDpin8に0Vを出力。
delayMicroseconds(T1); // 600usec offのまま。
}
void Zero(){
digitalWrite(2, HIGH); // LEDpin3に5Vを出力。
delayMicroseconds(T1); // 600usec onのまま。
digitalWrite(2, LOW); // LEDpin8に0Vを出力。
delayMicroseconds(T1); // 600usec offのまま。
}
void SignalOnOff(){
Leader();
One();
Zero();
One();
Zero();
One();
Zero();
Zero();
Zero();
One();
Zero();
One();
One();
Zero();
Zero();
One();
One();
One();
One();
One();
One();
delayMicroseconds(T18); //10800 usec offのまま
}
void loop(){
// send "Leader+10101000101100111111" for 3 times.
SignalOnOff();
SignalOnOff();
SignalOnOff();
delay(30000); //30秒待ちます。(連続でon/offしないため)
}
ここで公開するアイデア/装置は安全性を保障しておりません。 用途に応じた設計を行い、十分な安全検査を行ってからご利用ください。 本サイトの情報の営利目的での利用はご遠慮ください。 本サイトの内容の無断転載を禁じます。© 2010 TYK