电视助手(android+arduino+webserver)
本帖最后由 瘦网虫 于 2013-2-8 10:48 编辑对家里的有线电视的遥控进行了下周边的改造。
现在改为直接通过手机控制有线电视机顶盒。手机端附加了功能:读取、显示节目单。
实现原理:
web服务器从网上抓取一周所有的电视节目表,根据手机端发送的请求发送。
手机端显示本地的有线电视台列表(从服务器端取来)和对应的台的节目表,根据个人喜好进行台的切换。
切换台使用arduino+enc28j60网络模块监听网络udp消息,收到手机发来的换台、调音量等消息时,通过红外发送给有线电视机顶盒。
程序为简陋原型,后期闲的话,可以增加额外功能,例如预订节目等。
不知道有没有共同爱好者对此感兴趣。
先发截图,后发程序,再后发使用视频,最后发布可以使用的源代码。
2楼更新了android手机端程序。
3楼更新了arduino代码。 本帖最后由 瘦网虫 于 2013-2-8 14:57 编辑
手机端截图,由于资源限制,只做了本地的有线电视台对应频道列表。
如果爱好者多的话,更新数据库就可以了。
频道列表以及该频道当前节目
当前所有台的节目列表
点击上面链接下载android手机客户端。 本帖最后由 瘦网虫 于 2013-2-19 17:03 编辑
arduino端部分代码,自我觉得代码中有价值的部分就是发送有线电视控制信号部分。
发送 类型为unkown,长度为100的红外编码。
#include <EtherCard.h>
#include <IRremote.h>
static byte mymac[] = {
0x74,0x69,0x69,0x2D,0x30,0x31};
static byte myip[] = {
192,168,2,10};
// gateway ip address
static byte gwip[] = {
192,168,2,1 };
static byte dnsip[] = {
192,168,2,1 };
byte Ethernet::buffer;
static uint32_t timer;
#define gPB ether.buffer
#define UDP_DP_HIGH 36
#define UDP_DP_LOW 37
#define DSTPORT_HIHG 0x26
#define DSTPORT_LOW 0xe7
Stash stash;
const int CHANGE_CHANNEL = 1;
const int CHANGE_VOLUME = 2;
int cmd =0;
int cmdValue =-32768;
const int irReceiverPin = 7;
int STATUS_PIN = 13;
IRrecv irrecv(irReceiverPin); // 设置irReceiverPin定义的端口为红外信号接收端口
decode_results results; // 定义results变量为红外结果存放位置
IRsend irsend;
const int ledPin = 13;
boolean ledStatus;
char* on = "1";
char* off = "0";
char* statusLabel;
char* buttonLabel;
// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes; // The durations if raw
unsigned int rawCodes_voldown = {
3550 ,1850 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,450 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,1400 ,300 ,450 ,300 ,400 ,350 ,1400 ,300 ,1400 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,450 ,300 ,400 ,350 ,1400 ,300 ,1400 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,450 ,300 ,1400 ,350 ,1350 ,300 ,450 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,1400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,300 ,450 ,300
};//checked
unsigned int rawCodes_volup = {
3600 ,1800 ,300 ,450 ,300 ,450 ,300 ,400 ,350 ,1400 ,300 ,450 ,300 ,400 ,350 ,1400 ,300 ,450 ,300 ,400 ,350 ,1400 ,300 ,1400 ,350 ,350 ,350 ,400 ,350 ,400 ,350 ,1400 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,1400 ,300 ,1400 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,450 ,300 ,450 ,300 ,1400 ,300 ,1400 ,300 ,450 ,300 ,1400 ,350 ,400 ,300 ,450 ,300 ,1400 ,350 ,400 ,300 ,450 ,300 ,1400 ,350 ,400 ,300 ,1400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,300 ,1400 ,350 ,400 ,350 ,400 ,300 ,1400 ,350 ,400 ,350
};//checked
unsigned int rawCodes_channelup = {
3500 ,1850 ,300 ,450 ,250 ,500 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,500 ,250 ,1450 ,250 ,1450 ,300 ,450 ,300 ,450 ,250 ,500 ,250 ,1450 ,300 ,450 ,250 ,1450 ,300 ,450 ,300 ,450 ,250 ,1450 ,300 ,1450 ,250 ,450 ,300 ,1450 ,250 ,500 ,250 ,450 ,300 ,450 ,300 ,450 ,250 ,1450 ,300 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,500 ,250 ,500 ,250 ,500 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250
};//checked
unsigned int rawCodes_channeldown = {
3550 ,1850 ,300 ,450 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,400 ,350 ,1400 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,1400 ,300 ,1400 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,450 ,300 ,450 ,300 ,1400 ,300 ,1400 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,450 ,300 ,1400 ,300 ,450 ,300 ,1400 ,300 ,1400 ,300 ,1400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350
};//checked
unsigned int rawCodes_ok = {
3500 ,1900 ,250 ,500 ,250 ,450 ,300 ,450 ,300 ,1450 ,250 ,450 ,300 ,450 ,300 ,1450 ,250 ,450 ,300 ,450 ,300 ,1450 ,250 ,1450 ,250 ,500 ,250 ,500 ,250 ,450 ,300 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,500 ,250 ,1450 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,500 ,250 ,500 ,250 ,500 ,250 ,1450 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,500 ,250 ,500 ,250 ,1450 ,250 ,500 ,250 ,500 ,250 ,1450 ,250 ,1450 ,300 ,1400 ,300 ,450 ,300 ,450 ,300 ,1400 ,300 ,450 ,300
};//checked
unsigned int rawCodes_num1 = {
3550 ,1800 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,400 ,350
};
unsigned int rawCodes_num2 = {
3550 ,1850 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,350 ,350 ,350 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,1400 ,350 ,350 ,350 ,400 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,350 ,1400 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,350 ,400
};
unsigned int rawCodes_num3 = {
3600 ,1800 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,400 ,350
};
unsigned int rawCodes_num4 = {
3600 ,1800 ,350 ,350 ,350 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,1400 ,350 ,350 ,400 ,350 ,350 ,400 ,350 ,1400 ,350 ,350 ,350 ,1400 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,350 ,1400 ,350 ,350 ,400 ,1350 ,350 ,1350 ,350 ,350 ,400 ,350 ,400
};
unsigned int rawCodes_num5 = {
3600 ,1800 ,350 ,350 ,400 ,350 ,400 ,350 ,350 ,1400 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,350 ,400 ,1350 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,400 ,350
};
unsigned int rawCodes_num6 = {
3600 ,1800 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,400 ,350
};
unsigned int rawCodes_num7 = {
3600 ,1800 ,350 ,350 ,350 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,1400 ,350 ,350 ,400 ,350 ,350 ,400 ,350 ,1400 ,350 ,350 ,350 ,1400 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,350 ,400 ,1350 ,350 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,400 ,350
};
unsigned int rawCodes_num8 = {
3550 ,1850 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,1400 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,350 ,1400 ,350 ,1350 ,350 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1400 ,300 ,1400 ,350 ,1350 ,350 ,350 ,400 ,350 ,400
};
unsigned int rawCodes_num9 = {
3550 ,1800 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,1400 ,300 ,1400 ,350 ,350 ,350 ,1400 ,350 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,1400 ,300 ,1400 ,350 ,350 ,400 ,1350 ,350 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,350 ,400 ,350 ,1400 ,300 ,1400 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,350 ,400 ,350 ,350 ,1400 ,350 ,1350 ,350 ,1350 ,350 ,350 ,400 ,350 ,400
};
unsigned int rawCodes_num0 = {
3550 ,1800 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,350 ,350 ,1400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,400 ,300 ,1400 ,350 ,400 ,350 ,1350 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,300 ,1400 ,350 ,1400 ,300 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,400 ,350
};unsigned int rawCodes_invalid = {
3550 ,1800 ,350 ,350 ,350 ,350 ,350 ,400 ,350 ,1350 ,350 ,350 ,350 ,350 ,350 ,1350 ,350 ,350 ,350 ,350 ,350 ,1400 ,350 ,1350 ,350 ,350 ,350 ,400 ,350 ,400 ,300 ,1400 ,350 ,400 ,350 ,1350 ,350 ,350 ,350 ,400 ,350 ,1350 ,350 ,1350 ,350 ,400 ,350 ,1400 ,300 ,400 ,350 ,350 ,350 ,350 ,350 ,350 ,350 ,1350 ,350 ,1400 ,300 ,400 ,350 ,1400 ,300 ,400 ,350 ,350 ,350 ,350 ,350 ,400 ,350 ,400 ,300 ,1400 ,350 ,1400 ,300 ,400 ,350 ,350 ,350 ,400 ,350 ,400 ,350 ,400 ,350 ,350 ,400 ,1350 ,350 ,1350 ,350 ,400 ,350 ,400 ,350
};
//assign IR code in the map
unsigned int* codeMap =
{
//codeMap0-9
rawCodes_num0,rawCodes_num1,rawCodes_num2,rawCodes_num3,rawCodes_num4,rawCodes_num5,rawCodes_num6,rawCodes_num7,rawCodes_num8,rawCodes_num9,
rawCodes_channelup,//codeMap
rawCodes_channeldown,//codeMap
rawCodes_volup,//codeMap
rawCodes_voldown,//codeMap
rawCodes_ok,//codeMap
rawCodes_invalid//codeMap
};
//unsigned int* (*codeMap)={rawCodes_num0,rawCodes_num1};
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state
boolean dnsStatus = false;
int lastButtonState;
String cmdUrl;
void setup () {
Serial.begin(9600); // 开启串口,波特率为9600
irrecv.enableIRIn(); // 启动红外解码
pinMode(STATUS_PIN, OUTPUT);
//attachInterrupt(INT_NUM,handleCommand,CHANGE);
if (!ether.begin(sizeof Ethernet::buffer, mymac, 53))
Serial.println( "Failed to access Ethernet controller");
else
Serial.println("Ethernet controller initialized");
if (!ether.staticSetup(myip, gwip,dnsip))
Serial.println("Failed to set IP address");
//if (!ether.dhcpSetup())
// Serial.println("DHCP failed");
ether.printIp("IP:", ether.myip);
ether.printIp("GW:", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
Serial.println();
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
ledStatus = false;
}
void loop() {
if(!dnsStatus)
{
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
else dnsStatus = true;
ether.printIp("SRV: ", ether.hisip);
}
word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if (millis() > timer) {
timer = millis() + 10000;
Serial.println();
if(len)
{
if(gPB==IP_PROTO_UDP_V)
{
if((gPB==DSTPORT_HIHG)&&(gPB==DSTPORT_LOW))
{
Serial.println("---Received an udp 9959 packet---");
Serial.println((char *)gPB+42);
String cmdUrl =(char *)gPB+42;
cmd = getCmdValue(cmdUrl,"cmd");
cmdValue = getCmdValue(cmdUrl,"value");
if(cmd > 0)
{
handleCommand(cmd);
}
}
}
}
if (irrecv.decode(&results)) { // 解码成功,把数据放入results变量中
// 把数据输入到串口
Serial.print("irCode: ");
Serial.print(results.value, HEX); // 显示红外编码
Serial.print(",bits: ");
Serial.println(results.bits); // 显示红外编码位数
// digitalWrite(ledPin,HIGH);//LED点亮
// delay(10);
// digitalWrite(ledPin,LOW);//LED熄灭
irrecv.resume(); // 继续等待接收下一组信号
// irsend.sendRC6(0x30D0000A, 32);
// delay(10);
// irsend.sendRC6(0x30D0000A, 32);
}
}
void changeChannel(int chnId)
{
int chnDigi = 0;
for(int i = 100;i>0.1;i=i/10)
{
chnDigi = chnId/i;
remoterKeyPress(chnDigi,2);
//send invalid code between each key press
irsend.sendNEC(0xFFFFFFFF, 32);
chnId = chnId % i;
}
remoterKeyPress(14,1);
}
void remoterKeyPress(int mapId,int times)
{
for (int i = 0;i<times;i++)
{
irsend.sendRaw(codeMap, 100, 38);
delay(40);
Serial.println("Key Pressed");
Serial.println(mapId);
}
}
int getCmdValue(String str,char* cmd)
{
if(str.indexOf(cmd) == -1)
{
return cmdValue;
}
String temp = str.substring(str.indexOf(cmd)+strlen(cmd)+1);
if(temp.indexOf("&") > 0 )
{
cmdValue = temp.substring(0,temp.indexOf("&")).toInt();
}
else
{
cmdValue = temp.toInt();
}
return cmdValue;
}
void handleCommand(int cmd)
{
Serial.println("\n command requested..!");
switch (cmd)
{
case CHANGE_CHANNEL:
if(cmdValue > 0 )
{
changeChannel(cmdValue);
}
break;
case CHANGE_VOLUME:
if(cmdValue> 0 )
{
irsend.sendRaw(rawCodes_volup, 100, 38);
Serial.println("-------volume up---------");
}
else
{
irsend.sendRaw(rawCodes_voldown, 100, 38);
Serial.println("-------volume down---------");
}
break;
}
cmd = 0;
}
void sendCode(int repeat) {
if (codeType == NEC) {
if (repeat) {
irsend.sendNEC(REPEAT, codeLen);
Serial.println("Sent NEC repeat");
}
else {
irsend.sendNEC(codeValue, codeLen);
Serial.print("Sent NEC ");
Serial.println(codeValue, HEX);
}
}
else if (codeType == SONY) {
irsend.sendSony(codeValue, codeLen);
Serial.print("Sent Sony ");
Serial.println(codeValue, HEX);
}
else if (codeType == RC5 || codeType == RC6) {
if (!repeat) {
// Flip the toggle bit for a new button press
toggle = 1 - toggle;
}
// Put the toggle bit into the code to send
codeValue = codeValue & ~(1 << (codeLen - 1));
codeValue = codeValue | (toggle << (codeLen - 1));
if (codeType == RC5) {
Serial.print("Sent RC5 ");
Serial.println(codeValue, HEX);
irsend.sendRC5(codeValue, codeLen);
}
else {
irsend.sendRC6(codeValue, codeLen);
Serial.print("Sent RC6 ");
Serial.println(codeValue, HEX);
}
}
else if (codeType == UNKNOWN /* i.e. raw */) {
// Assume 38 KHz
// irsend.sendRaw(rawCodes, codeLen, 38);
irsend.sendRaw(rawCodes_volup, 100, 38);
Serial.println("Sent raw");
}
}
好东西,感谢楼主分享。 这个有意思,红外能控制空调我感兴趣,或者直接控制继电器,带一些东西。 感觉智能手机还是不应该取消红外这个外设,有没有直接usb的红外发射器,接到手机上面直接用更方便。 laoliu1982 发表于 2013-2-7 14:46 static/image/common/back.gif
感觉智能手机还是不应该取消红外这个外设,有没有直接usb的红外发射器,接到手机上面直接用更方便。
按照我的猜想,手机的耳机插孔直接接红外发射应该有可能实现。
等有空来做个测试。 瘦网虫 发表于 2013-2-7 14:49 static/image/common/back.gif
按照我的猜想,手机的耳机插孔直接接红外发射应该有可能实现。
等有空来做个测试。
这个有成功案例,只是自己测试老不成功,毕竟红外式工作在40kzh ,而音频最高为20kzh 最近也在玩红外,刚开始入门
楼主思路很好,要是能将数据保存在姜工的服务器上就好了。 yyy_zc 发表于 2013-2-7 17:14 static/image/common/back.gif
这个有成功案例,只是自己测试老不成功,毕竟红外式工作在40kzh ,而音频最高为20kzh
。。红外的东西不都是开关信号吗。。什么频率的都不是重点吧 幻生幻灭 发表于 2013-2-7 17:23 static/image/common/back.gif
最近也在玩红外,刚开始入门
楼主思路很好,要是能将数据保存在姜工的服务器上就好了。
数据是公开的(数据来源:搜视网http://epg.tvsou.com/),现在还是程序原型阶段,放服务器担心把它拖死了,自己在互联网上临时架设了个服务器,呵呵。
另,姜工服务器是什么? http://www.yeelink.net/
据姜工说可以,但我没弄过 好东西。万恶的广电部把机顶盒弄成了封闭系统,不能联网。 这个太屌了 我得mark一下 我用的机顶盒都是安卓系统;P
页:
[1]
2