首页/作品列表/mCookie红外遥控点阵屏
mCookie红外遥控点阵屏
3580 0
主要内容
#include <Arduino.h>
#include <Microduino_Key.h>
#include <IRremote.h>
AnalogKey keyAnalog2[5] {(A2),(A2),(A2),(A2),(A2)};

IRsend irsend;

void setup()
{
    Serial.begin(9600);
    for (uint8_t a = 0; a < 5; a++)
    {
        keyAnalog2[a].begin(INPUT);
    }


}

void loop()
{
    delay(0.2*1000);
    if((keyAnalog2[1].readVal(700 - 50, 700 + 50,KEY_PRESSING)))
    {
        irsend.sendRC5(1,32);
        Serial.println("up");

    }
    if((keyAnalog2[2].readVal(330 - 50, 330 + 50,KEY_PRESSING)))
    {
        irsend.sendRC5(2,32);
        Serial.println("down ");

    }
    if((keyAnalog2[3].readVal(512 - 50, 512 + 50,KEY_PRESSING)))
    {
        irsend.sendRC5(3,32);
        Serial.println("left");

    }
    if((keyAnalog2[4].readVal(860 - 50, 860 + 50,KEY_PRESSING)))
    {
        irsend.sendRC5(4,32);
        Serial.println("right ");

    }
    if((keyAnalog2[0].readVal(0, 50,KEY_PRESSING)))
    {
        irsend.sendRC5(5,32);
        Serial.println("center ");

    }

}

#include <Arduino.h>
#include <IRremote.h>

#include <Microduino_Matrix.h>
int var_x;

int var_y;

int var_oldx;

int var_oldy;

long var_command;

long ir_item;
IRrecv irrecv_2(2);
decode_results results_2;
uint32_t _irData = 0x00000000;
uint32_t _irDataCache = 0x00000000;
uint32_t dump(decode_results *results)
{
    int count = results->rawlen;
    if (results->decode_type == UNKNOWN)
    {
    }
    else
    {
        if (results->decode_type == NEC)
        {
        }
        _irDataCache = _irData;
        if (results->value == 0xFFFFFFFF)
        {
            _irData = _irDataCache;
        }
        else
        {
            _irData = results->value;
        }
    }
}
uint32_t _irTime = 0;
uint32_t irFluse()
{
    if (irrecv_2.decode(&results_2))
    {
        dump(&results_2);
        irrecv_2.resume();
        _irTime = millis();
    }
    if (millis() - _irTime > 200)
    {
        _irData = 0x00000000;
    }
    return _irData;
}
uint8_t Addr[MatrixPix_X][MatrixPix_Y] =
{
    {
        64
    }
}
;
Matrix display = Matrix(Addr, TYPE_COLOR);


void setup()
{
    Serial.begin(9600);
    Serial.begin(9600);

    irrecv_2.enableIRIn();
    Wire.begin();

    var_x=0;
    var_y=0;

}

void loop()
{
    var_command=irFluse();
    Serial.println(var_command);
    var_oldx=var_x;
    var_oldy=var_y;
    if(((var_command) == 1))
    {
        var_y=(var_y)-1;

    }
    if(((var_command) == 2))
    {
        var_y=(var_y)+1;

    }
    if(((var_command) == 3))
    {
        var_x=(var_x)-1;

    }
    if(((var_command) == 4))
    {
        var_x=(var_x)+1;

    }
    if(((var_command) == 5))
    {
        var_x=0;
        var_y=0;

    }
    display.setLedColor(var_oldx, var_oldy, (0x000000)>>16, (0x000000)>>8&0xFF, (0x000000)&0xFF);
    display.setLedColor(var_x, var_y, (0xff0000)>>16, (0xff0000)>>8&0xFF, (0xff0000)&0xFF);
    delay(0.2*1000);

}
代码展示
暂无数据!
附件下载
  • 资料展示
  • 工程认知.zip
0
大牛,别默默的看了,快登录帮我点评一下吧!

立即注册