Close

mitch

Vytvořené odpovědi

Aktuálně je na stránce zobrazeno 8 příspěvků - 1. až 8. (celkem z 8)
  • Autor
    Příspěvky
  • odpověď na: IR ovladač #6924
    mitch
    Účastník

    Ještě obrázky. Nějak dlouho trvá než se vždy příspěvek odešle 🙂

    odpověď na: IR ovladač #6922
    mitch
    Účastník

    S tím děličem si měl pravdu. Pouze chyba při kreslení. Dělal jsem to z hlavy, ale zapojené jsem to měl dobře 🙂
    Pro jistotu jsem tam přidal ty odpory jak jsi zmiňoval. Vzal jsem co jsem našel v šuplíku 🙂
    Výrobek je hotový a teď už ho jen zamontovat za TV a natahat finálně kabeláž 🙂

    Attachments:
    odpověď na: IR ovladač #6918
    mitch
    Účastník

    Tak snad jsem na nic nezapomněl 🙂
    Poprvé co jsem kreslil schéma v Eagle tak snad dobrý 🙂

    Attachments:
    odpověď na: IR ovladač #6907
    mitch
    Účastník

    Abych to shrnul 🙂
    Chci poděkovat všem za cenné rady. Prvním problémem bylo skutečně ovlivňování signálů. Čili tam pomohlo vysílaný signál zpozdit o 100ms.
    Ohledně paměti pomohlo přenést vysílací kódy pomocí PROGMEM.
    Nyní jsem s pamětí takto:

    Projekt zabírá 22 790 bytů (74%)  úložného místa pro program. Maximum je 30 720 bytů.
    Globální proměnné zabírají 816 bytů (39%)  dynamické paměti, 1 232 bytů zůstává pro lokální proměnné. Maximum je 2 048 bytů.

    Celé to funguje tak, že při spuštěné TV (signál z USB od TV do Arduina). Automaticky se zapne LED páska za TV a vyšle se Power kód pro STB.
    Jinak mám STB značky Hybroad Z205. Je to kabelový STB pro IPTV. Při vypnutí TV se opět vyšle kód na vypnutí STB.
    Dále to překládá kódy z ovladače pro Samsung TV a posílá je do STB. Na TV jsem nastavil funkci univerzálního dálkového ovladače, ale protože tento můj STB není v seznamu tak jsem zvolil libovolný, aby si TV myslela, že tam je a např. barevný tlačítka nereagovaly a nezobrazovala se hláška „Není k dispozici“.
    Dále tam mám BT modul HC-06, přes který se dá jak TV tak i STB ovládat z telefonu.
    Kód může být pro někoho prasárna, ale je to první funkční projekt 🙂
    Schéma zapojení dodám, až ho nakreslím.

    A nakonec samotný kód, pokud by se někomu hodil 🙂

    #include <IRremote.h>
    
    // Deklarace pinů
    #define RECV_PIN 11
    #define TVpin 2
    #define LEDpin 5
    #define tvLEDpin 13
    
    // STB
    const unsigned int srPower[67] PROGMEM = {8950, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 1600, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650}; // NEC 20250AF
    const unsigned int srMute[67] PROGMEM = {8900, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 1550, 650, 1600, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 1600, 600, 500, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650}; // NEC 20230CF
    const unsigned int srHelp[67] PROGMEM = {8950, 4350, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 700, 400, 650, 500, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 202F00F
    const unsigned int sr1[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650}; // NEC 202807F
    const unsigned int sr2[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 20240BF
    const unsigned int sr3[67] PROGMEM = {8950, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 1600, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 202C03F
    const unsigned int sr4[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650}; // NEC 20220DF
    const unsigned int sr5[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 1600, 650, 450, 650, 1600, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 202A05F
    const unsigned int sr6[67] PROGMEM = {8900, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 202609F
    const unsigned int sr7[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650}; // NEC 202E01F
    const unsigned int sr8[67] PROGMEM = {8950, 4350, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 1600, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 20210EF
    const unsigned int sr9[67] PROGMEM = {8900, 4350, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 1600, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 1600, 600, 500, 600, 1600, 600, 1600, 650, 1600, 600, 1600, 650}; // NEC 202906F
    const unsigned int sr0[67] PROGMEM = {8950, 4300, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 20200FF
    const unsigned int srDisplay[67] PROGMEM = {8950, 4300, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 1600, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 1550, 650, 500, 600, 1600, 650}; // NEC 202A25D
    const unsigned int srClear[67] PROGMEM = {8950, 4350, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 1600, 600, 500, 600, 1600, 650, 1600, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 500, 650, 450, 600, 1600, 650, 1600, 600, 1600, 650}; // NEC 202B847
    const unsigned int srPUp[67] PROGMEM = {8900, 4350, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 1600, 650, 450, 650, 1600, 600, 1600, 650, 1600, 600, 1600, 600, 500, 650, 1600, 600}; // NEC 20242BD
    const unsigned int srPDown[67] PROGMEM = {8950, 4350, 650, 450, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 20258A7
    const unsigned int srExit[67] PROGMEM = {8900, 4350, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650, 450, 650, 1550, 650}; // NEC 20202FD
    const unsigned int srBack[67] PROGMEM = {8900, 4350, 650, 450, 650, 450, 650, 450, 600, 500, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 600, 1600, 650, 500, 600, 1600, 600, 500, 650, 450, 600, 500, 600, 500, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 1600, 600, 1650, 600, 1600, 600, 1600, 650, 1600, 600, 500, 650, 1550, 650}; // NEC 202827D
    const unsigned int srUp[67] PROGMEM = {8950, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 1600, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 202D02F
    const unsigned int srDown[67] PROGMEM = {8950, 4300, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1550, 650, 500, 600, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 202708F
    const unsigned int srLeft[67] PROGMEM = {8950, 4350, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 600, 500, 600, 1600, 650, 1600, 600, 1600, 650}; // NEC 20208F7
    const unsigned int srRight[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 2028877
    const unsigned int srOK[67] PROGMEM = {8900, 4350, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 600, 500, 650, 450, 650, 1600, 600, 500, 650, 1550, 650, 450, 650, 1600, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650}; // NEC 202B04F
    const unsigned int srPPlus[67] PROGMEM = {8950, 4350, 600, 500, 600, 500, 650, 450, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 202A857
    const unsigned int srPMinus[67] PROGMEM = {8900, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 600, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 20238C7
    const unsigned int srVPlus[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 202F807
    const unsigned int srVMinus[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1600, 600, 1600, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650}; // NEC 2027887
    const unsigned int srMenu[67] PROGMEM = {8950, 4300, 650, 450, 700, 400, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 700, 400, 700, 400, 650, 450, 700, 400, 700, 450, 600, 500, 600, 1600, 650, 450, 650, 450, 700, 1550, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 700, 400, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 20248B7
    const unsigned int srRev[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 700, 400, 700, 400, 700, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 700, 400, 650, 450, 650, 1600, 650, 1550, 700, 400, 700, 1550, 650, 1550, 650, 1600, 600}; // NEC 202C837
    const unsigned int srFwd[67] PROGMEM = {8900, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 650, 1550, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 202D827
    const unsigned int srPlay[67] PROGMEM = {9000, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 500, 600, 500, 600, 1600, 650, 450, 650, 1550, 650, 450, 650, 500, 600, 500, 650, 1550, 650, 1550, 650, 450, 700, 1550, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 20228D7
    const unsigned int srStop[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 700, 400, 650, 450, 700, 1550, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 1600, 600}; // NEC 20222DD
    const unsigned int srSubtitle[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 1600, 650, 450, 650, 1600, 600, 1600, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 1600, 650, 450, 650, 1550, 650, 450, 650, 1600, 650}; // NEC 202CA35
    const unsigned int srAudio[67] PROGMEM = {8900, 4350, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 550, 550, 600, 1600, 600, 1650, 550, 550, 600, 1600, 600, 1600, 600, 500, 600, 1650, 550, 550, 600, 500, 600, 500, 600, 1650, 550, 550, 550, 550, 550, 1650, 600, 500, 600, 1650, 550}; // NEC 202DA25
    const unsigned int srRec[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 700, 400, 700, 400, 700, 450, 650, 1550, 650, 450, 650, 450, 700, 400, 700, 400, 700, 400, 700, 400, 700, 400, 700, 1550, 650, 450, 650, 1550, 700, 1550, 650, 1550, 650, 450, 700, 1550, 600, 500, 650, 1550, 650, 450, 700, 400, 700, 400, 700, 400, 650, 1600, 650, 450, 650, 1550, 650, 450, 700, 1550, 650}; // NEC 202EA15
    const unsigned int srGoto[67] PROGMEM = {8950, 4300, 700, 400, 700, 400, 700, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 700, 400, 700, 400, 700, 400, 700, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 700, 400, 700, 400, 700, 1550, 650, 450, 650, 1550, 700, 400, 700, 1550, 650, 450, 650, 1550, 700, 1550, 650, 450, 650, 1550, 650, 450, 650, 1550, 700, 450, 650, 1550, 650}; // NEC 2022AD5
    const unsigned int srRed[67] PROGMEM = {8950, 4350, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 2026897
    const unsigned int srGreen[67] PROGMEM = {8900, 4350, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 550, 550, 1650, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 600, 500, 600, 1600, 600, 1650, 600, 1600, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 1600, 650, 1550, 650, 1600, 650}; // NEC 202E817
    const unsigned int srBlue[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 700, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 1600, 650, 1550, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650}; // NEC 20218E7
    const unsigned int srYellow[67] PROGMEM = {8950, 4300, 650, 450, 650, 450, 700, 400, 650, 450, 650, 450, 700, 400, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 700, 400, 700, 400, 650, 1600, 650, 450, 650, 1550, 650, 450, 650, 450, 700, 1550, 650, 1550, 650, 450, 700, 400, 700, 400, 650, 450, 650, 1600, 650, 1550, 650, 450, 700, 400, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 2029867
    
    // TV
    #define tPower 0xE0E040BF
    #define tPowerS 0xE0E007F8
    #define tSource 0xE0E0807F
    #define t1 0xE0E020DF
    #define t2 0xE0E0A05F
    #define t3 0xE0E0609F
    #define t4 0xE0E010EF
    #define t5 0xE0E0906F
    #define t6 0xE0E050AF
    #define t7 0xE0E030CF
    #define t8 0xE0E0B04F
    #define t9 0xE0E0708F
    #define t0 0xE0E08877
    #define tTTX 0xE0E034CB
    #define tPRECH 0xE0E0C837
    #define tMute 0xE0E0F00F
    #define tVUp 0xE0E0E01F
    #define tVDown 0xE0E0D02F
    #define tPUp 0xE0E048B7
    #define tPDown 0xE0E008F7
    #define tCHlist 0xE0E0D629
    #define tMenu 0xE0E058A7
    #define tSmart 0xE0E09E61
    #define tGuide 0xE0E0F20D
    #define tTools 0xE0E0D22D
    #define tInfo 0xE0E0F807
    #define tUp 0xE0E006F9
    #define tDown 0xE0E08679
    #define tLeft 0xE0E0A659
    #define tRight 0xE0E046B9
    #define tOK 0xE0E016E9
    #define tReturn 0xE0E01AE5
    #define tExit 0xE0E0B44B
    #define tRev 0xE0E0A25D
    #define tFwd 0xE0E012ED
    #define tPause 0xE0E052AD
    #define tPlay 0xE0E0E21D
    #define tRec 0xE0E0926D
    #define tStop 0xE0E0629D
    #define tRed 0xE0E036C9
    #define tGreen 0xE0E028D7
    #define tYellow 0xE0E0A857
    #define tBlue 0xE0E06897
    const unsigned int trPower[67] PROGMEM = {4550, 4400, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 650, 450, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 1550, 650, 500, 650, 1550, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650}; // SAMSUNG E0E040BF
    const unsigned int trSource[67] PROGMEM = {4600, 4350, 650, 1600, 650, 1550, 700, 1550, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 1550, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650}; // SAMSUNG E0E0807F
    const unsigned int trMute[67] PROGMEM = {4550, 4350, 650, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 650, 450, 650, 450, 650, 1600, 600, 1600, 650, 1600, 650, 1550, 650}; // SAMSUNG E0E0F00F
    const unsigned int trVUp[67] PROGMEM = {4600, 4350, 650, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650}; // SAMSUNG E0E0E01F
    const unsigned int trVDown[67] PROGMEM = {4600, 4350, 650, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 500, 650, 450, 600, 500, 650, 450, 650, 1600, 600, 1600, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650}; // SAMSUNG E0E0D02F
    const unsigned int trMenu[67] PROGMEM = {4550, 4400, 650, 1550, 700, 1550, 650, 1550, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 500, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650}; // SAMSUNG E0E058A7
    const unsigned int trSmart[67] PROGMEM = {4600, 4350, 650, 1600, 650, 1550, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 500, 650, 1550, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650}; // SAMSUNG E0E09E61
    const unsigned int trTools[67] PROGMEM = {4550, 4400, 650, 1600, 600, 1600, 650, 1600, 600, 500, 600, 500, 650, 450, 650, 500, 600, 500, 600, 1600, 650, 1600, 600, 1600, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 600, 1600, 650, 500, 550, 1650, 600, 500, 650, 450, 600, 1650, 600, 500, 600, 500, 600, 550, 600, 1600, 600, 500, 600, 1650, 600, 1600, 650, 450, 600, 1650, 600}; // SAMSUNG E0E0D22D
    const unsigned int trUp[67] PROGMEM = {4550, 4400, 600, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 1600, 600, 1600, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 500, 650, 450, 650, 1550, 650}; // SAMSUNG E0E006F9
    const unsigned int trDown[67] PROGMEM = {4550, 4350, 650, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 500, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 450, 650, 1600, 600}; // SAMSUNG E0E08679
    const unsigned int trLeft[67] PROGMEM = {4600, 4350, 650, 1550, 650, 1600, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 450, 650, 500, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 1600, 650}; // SAMSUNG E0E0A659
    const unsigned int trRight[67] PROGMEM = {4500, 4450, 600, 1650, 550, 1650, 600, 1650, 550, 550, 550, 550, 550, 550, 600, 500, 600, 550, 550, 1650, 600, 1650, 550, 1650, 600, 500, 600, 550, 550, 550, 550, 550, 600, 500, 550, 600, 550, 1650, 550, 550, 550, 550, 600, 550, 550, 1650, 600, 1650, 550, 550, 550, 1650, 600, 550, 550, 1650, 550, 1700, 550, 1650, 550, 550, 550, 550, 600, 1650, 550}; // SAMSUNG E0E046B9
    const unsigned int trOK[67] PROGMEM = {4550, 4350, 650, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1600, 650, 1550, 700, 1550, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 1550, 650}; // SAMSUNG E0E016E9
    const unsigned int trReturn[67] PROGMEM = {4600, 4350, 650, 1600, 650, 1550, 700, 1550, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 700, 450, 650, 450, 650, 450, 700, 1550, 650, 1550, 650, 450, 700, 1550, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 500, 650, 450, 650, 1550, 650, 500, 650, 1550, 650}; // SAMSUNG E0E01AE5
    const unsigned int trExit[67] PROGMEM = {4600, 4350, 650, 1600, 600, 1600, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 500, 600, 500, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650}; // SAMSUNG E0E0B44B
    const unsigned int trRev[67] PROGMEM = {4550, 4400, 650, 1600, 600, 1600, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 600, 1600, 650, 1600, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1600, 650, 450, 700, 1550, 650, 1550, 700, 1500, 650, 500, 650, 1550, 700}; // SAMSUNG E0E0A25D
    const unsigned int trFwd[67] PROGMEM = {4550, 4400, 650, 1550, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1600, 650, 1550, 650, 1550, 650, 500, 650, 1550, 650, 1600, 650, 450, 650, 1550, 650}; // SAMSUNG E0E012ED
    const unsigned int trPause[67] PROGMEM = {4550, 4400, 650, 1600, 600, 1600, 650, 1600, 600, 500, 600, 500, 650, 450, 600, 550, 600, 500, 600, 1600, 650, 1600, 600, 1600, 650, 450, 600, 550, 600, 500, 600, 500, 600, 500, 600, 550, 600, 1600, 600, 500, 600, 1650, 600, 500, 600, 500, 600, 1650, 600, 500, 600, 1600, 600, 550, 600, 1600, 600, 500, 600, 1650, 600, 1600, 600, 550, 550, 1650, 600}; // SAMSUNG E0E052AD
    const unsigned int trPlay[67] PROGMEM = {4600, 4350, 650, 1600, 650, 1550, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 500, 650, 1550, 650, 1600, 650, 1550, 650, 450, 700, 400, 700, 450, 650, 450, 650, 450, 700, 1550, 650, 1550, 700, 1550, 650, 450, 650, 450, 700, 400, 700, 1550, 650, 450, 650, 450, 700, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 1600, 650}; // SAMSUNG E0E0E21D
    const unsigned int trStop[67] PROGMEM = {4500, 4400, 650, 1600, 600, 1600, 600, 1650, 550, 550, 550, 550, 600, 500, 600, 550, 550, 550, 550, 1650, 550, 1700, 550, 1650, 550, 600, 550, 550, 550, 550, 550, 550, 550, 550, 600, 550, 550, 1650, 600, 1650, 550, 550, 550, 550, 600, 500, 600, 1650, 550, 550, 600, 1650, 550, 550, 600, 500, 600, 1600, 600, 1650, 600, 1600, 600, 550, 600, 1600, 600}; // SAMSUNG E0E0629D
    
    // Definice IR
    IRrecv irrecv(RECV_PIN);
    IRsend irsend;
    decode_results results;
    
    // Proměnné
    bool doSTB = 1;
    bool doSTBlast = 1;
    bool TVstate = 0;
    long TVstateChange = 0;
    int LEDstate = 0;
    unsigned long LEDdelay = 5 * 60 * 1000;
    String BTin = "";
    boolean BTok = false;
    
    void setup()
    {
      Serial.begin(9600);
      irrecv.enableIRIn(); // Start the receiver
      pinMode(TVpin, INPUT);
      pinMode(LEDpin, OUTPUT);
      analogWrite(LEDpin, LEDstate);
      pinMode(tvLEDpin, OUTPUT);
      digitalWrite(tvLEDpin, LOW);
      BTin.reserve(20);
    
      if (digitalRead(TVpin)) {
        TVstate = 1;
        LEDstate = 255;
        analogWrite(LEDpin, LEDstate);
      }
    }
    
    void loop() {
      // Rozsvítí kontrolku když jde ovládání jen do TV
      // -----------------------------------------------------------------
      if (doSTB != doSTBlast) {
        if (doSTB == 0) {
          digitalWrite(tvLEDpin, HIGH);
        } else {
          digitalWrite(tvLEDpin, LOW);
        }
        doSTBlast = doSTB;
      }
    
      // Detekce vypnuté/zapnuté TV
      // -----------------------------------------------------------------
      if (digitalRead(TVpin) != TVstate) {
        //Serial.print(F("Aktualni stav TV: "));
        //Serial.println(digitalRead(TVpin));
        TVstate = digitalRead(TVpin);
    
        if (digitalRead(TVpin)) {
          LEDstate = 255;
          TVstateChange = 0;
        } else {
          TVstateChange = millis() + LEDdelay;
        }
        Serial.print(TVstate);
        Serial.print(F("|"));
        Serial.println(LEDstate);
        analogWrite(LEDpin, LEDstate);
        Odeslat(srPower, "Vypinam/zapinam STB");
      }
    
      // Zpožděné vypnutí LED
      if (TVstateChange > 0 && millis() > TVstateChange) {
        LEDstate = 0;
        TVstateChange = 0;
        analogWrite(LEDpin, LEDstate);
        Serial.print(TVstate);
        Serial.print(F("|"));
        Serial.println(LEDstate);
      }
    
      if (BTok) {
        //Serial.print(F("Prijaty prikaz z BT: "));
        //Serial.println(BTin);
    
        // Změna intenzity led
        if (BTin.indexOf("led=") > -1) {
          LEDstate = BTin.substring(BTin.indexOf("=") + 1).toInt();
          analogWrite(LEDpin, LEDstate);
        }
    
        if (BTin == "Connected") { // Když se připojí BT
          Serial.print(TVstate);
          Serial.print(F("|"));
          Serial.println(LEDstate);
        } else if (BTin == "Red") {
          Odeslat(srRed, "srRed");
        } else if (BTin == "Green") {
          Odeslat(srGreen, "srGreen");
        } else if (BTin == "Yellow") {
          Odeslat(srYellow, "srYellow");
        } else if (BTin == "Blue") {
          Odeslat(srBlue, "srBlue");
        } else if (BTin == "PowerTV") {
          Odeslat(trPower, "trPower");
        } else if (BTin == "Source") {
          doSTB = 0;
          Odeslat(trSource, "trSource");
        } else if (BTin == "PowerSTB") {
          Odeslat(srPower, "srPower");
        } else if (BTin == "1") {
          Odeslat(sr1, "sr1");
        } else if (BTin == "2") {
          Odeslat(sr2, "sr2");
        } else if (BTin == "3") {
          Odeslat(sr3, "sr3");
        } else if (BTin == "4") {
          Odeslat(sr4, "sr4");
        } else if (BTin == "5") {
          Odeslat(sr5, "sr5");
        } else if (BTin == "6") {
          Odeslat(sr6, "sr6");
        } else if (BTin == "7") {
          Odeslat(sr7, "sr7");
        } else if (BTin == "8") {
          Odeslat(sr8, "sr8");
        } else if (BTin == "9") {
          Odeslat(sr9, "sr9");
        } else if (BTin == "0") {
          Odeslat(sr0, "sr0");
        } else if (BTin == "VUp") {
          Odeslat(trVUp, "trVUp");
        } else if (BTin == "VDown") {
          Odeslat(trVDown, "trVDown");
        } else if (BTin == "PUp") {
          Odeslat(srPUp, "srPUp");
        } else if (BTin == "PDown") {
          Odeslat(srPDown, "srPDown");
        } else if (BTin == "Mute") {
          Odeslat(trMute, "trMute");
        } else if (BTin == "Smart") {
          doSTB = 0;
          Odeslat(trSmart, "trSmart");
        } else if (BTin == "Tools") {
          doSTB = 0;
          Odeslat(trTools, "trTools");
        } else if (BTin == "Menu") {
          doSTB = 0;
          Odeslat(trMenu, "trMenu");
        } else if (BTin == "Return") {
          Odeslat(trReturn, "trReturn");
        } else if (BTin == "Exit") {
          doSTB = 1;
          Odeslat(trExit, "trExit");
    
        } else if (BTin == "Up") {
          if (doSTB) {
            Odeslat(srUp, "srUp");
          } else {
            Odeslat(trUp, "trUp");
          }
        } else if (BTin == "Down") {
          if (doSTB) {
            Odeslat(srDown, "srDown");
          } else {
            Odeslat(trDown, "trDown");
          }
        } else if (BTin == "Left") {
          if (doSTB) {
            Odeslat(srLeft, "srLeft");
          } else {
            Odeslat(trLeft, "trLeft");
          }
        } else if (BTin == "Right") {
          if (doSTB) {
            Odeslat(srRight, "srRight");
          } else {
            Odeslat(trRight, "trRight");
          }
        } else if (BTin == "OK") {
          if (doSTB) {
            Odeslat(srOK, "srOK");
          } else {
            Odeslat(trOK, "trOK");
          }
    
        } else if (BTin == "Rev") {
          if (doSTB) {
            Odeslat(srRev, "srRev");
          } else {
            Odeslat(trRev, "trRev");
          }
        } else if (BTin == "Play") {
          if (doSTB) {
            Odeslat(srPlay, "srPlay");
          } else {
            Odeslat(trPlay, "trPlay");
          }
        } else if (BTin == "Pause") {
          if (doSTB) {
            Odeslat(srPlay, "srPlay");
          } else {
            Odeslat(trPause, "trPause");
          }
        } else if (BTin == "Fwd") {
          if (doSTB) {
            Odeslat(srFwd, "srFwd");
          } else {
            Odeslat(trFwd, "trFwd");
          }
        } else if (BTin == "Stop") {
          if (doSTB) {
            Odeslat(srStop, "srStop");
          } else {
            Odeslat(trStop, "trStop");
          }
        } else if (BTin == "Rec") {
          Odeslat(srRec, "srRec");
        }
    
        BTin = "";
        BTok = false;
      }
    
      // Rozpoznání přijatého kódu
      // -----------------------------------------------------------------
      if (irrecv.decode(&results)) {
        //Serial.print(F("Prijato: "));
        //Serial.println(results.value, HEX);
    
        switch (results.value) {
          case tYellow:
            Odeslat(srYellow, "srYellow");
            break;
          case tBlue:
            Odeslat(srBlue, "srBlue");
            break;
          case tRed:
            Odeslat(srRed, "srRed");
            break;
          case tGreen:
            Odeslat(srGreen, "srGreen");
            break;
          case tUp:
            Odeslat(srUp, "srUp");
            break;
          case tDown:
            Odeslat(srDown, "srDown");
            break;
          case tLeft:
            Odeslat(srLeft, "srLeft");
            break;
          case tRight:
            Odeslat(srRight, "srRight");
            break;
          case tOK:
            Odeslat(srOK, "srOK");
            break;
          case tPUp:
            Odeslat(srPUp, "srPUp");
            break;
          case tPDown:
            Odeslat(srPDown, "srPDown");
            break;
          case tPlay:
            Odeslat(srPlay, "srPlay");
            break;
          case tPause:
            Odeslat(srPlay, "srPlay");
            break;
          case tStop:
            Odeslat(srStop, "srStop");
            break;
          case tRev:
            Odeslat(srRev, "srRev");
            break;
          case tFwd:
            Odeslat(srFwd, "srFwd");
            break;
          case tRec:
            Odeslat(srRec, "srRec");
            break;
          case tPRECH:
            Odeslat(srClear, "srClear");
            break;
          case tPowerS:
            Odeslat(srPower, "srPower");
            break;
          case t1:
            Odeslat(sr1, "sr1");
            break;
          case t2:
            Odeslat(sr2, "sr2");
            break;
          case t3:
            Odeslat(sr3, "sr3");
            break;
          case t4:
            Odeslat(sr4, "sr4");
            break;
          case t5:
            Odeslat(sr5, "sr5");
            break;
          case t6:
            Odeslat(sr6, "sr6");
            break;
          case t7:
            Odeslat(sr7, "sr7");
            break;
          case t8:
            Odeslat(sr8, "sr8");
            break;
          case t9:
            Odeslat(sr9, "sr9");
            break;
          case t0:
            Odeslat(sr0, "sr0");
            break;
    
          case tSource:
            doSTB = 0;
            //Serial.println(F("Vypinam prevod do STB"));
            break;
          case tSmart:
            doSTB = 0;
            //Serial.println(F("Vypinam prevod do STB"));
            break;
          case tMenu:
            doSTB = 0;
            //Serial.println(F("Vypinam prevod do STB"));
            break;
          case tTools:
            doSTB = 0;
            //Serial.println(F("Vypinam prevod do STB"));
            break;
          case tExit:
            doSTB = 1;
            //Serial.println(F("Zapinam prevod do STB"));
            break;
    
          case tGuide:
            if (LEDstate == 0) {
              LEDstate = 255;
            } else {
              LEDstate = 0;
            }
            analogWrite(LEDpin, LEDstate);
            Serial.print(TVstate);
            Serial.print(F("|"));
            Serial.println(LEDstate);
            break;
        }
        irrecv.resume(); // Receive the next value
      }
    }
    
    unsigned int Odeslat(const unsigned int* Kod, char* text) {
      unsigned int raw[67];
      for (int i = 0; i < 67; i++) {
        raw[i] = pgm_read_word_near(Kod + i);
      }
    
      if (doSTB || text[0] == 't') {
        delay(100); // Zpožděné odeslání
        irsend.sendRaw(raw, 67, 38);
        //Serial.print(F("Odesilam kod: "));
        //Serial.println(text);
        irrecv.enableIRIn();
      }
    
    }
    
    void serialEvent() {
      while (Serial.available()) {
        char inChar = (char)Serial.read();
        //Serial.println(inChar);
        if (inChar == ';') {
          BTok = true;
        } else {
          BTin += inChar;
        }
      }
    }
    
    odpověď na: IR ovladač #6883
    mitch
    Účastník

    Koukám, že se ohledně Arduina mám ještě hodně co učit 🙂 momentálně jsem spadnul pomocí PROGMEM na nějakých 440bytů 🙂
    Zatím díky moc 🙂

    odpověď na: IR ovladač #6879
    mitch
    Účastník

    Tak pauza před odeslání je asi to pravé řešení. Stačí dát delay(100); a už to odesílá. Nyní jsem ale narazil na jiný problém a to:

    Projekt zabírá 14 692 bytů (47%)  úložného místa pro program. Maximum je 30 720 bytů.
    Globální proměnné zabírají 3 924 bytů (191%)  dynamické paměti, -1 876 bytů zůstává pro lokální proměnné. Maximum je 2 048 bytů.
    processing.app.debug.RunnerException: Nedostatek peměti;

    Aktuální kód je tento:

    #include <IRremote.h>
    
    // Deklarace pinů
    int RECV_PIN = 11;
    
    // STB
    const unsigned int srPower[67] = {8950, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 1600, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650}; // NEC 20250AF
    const unsigned int srMute[67] = {8900, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 1550, 650, 1600, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 1600, 600, 500, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650}; // NEC 20230CF
    const unsigned int srHelp[67] = {8950, 4350, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 700, 400, 650, 500, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 202F00F
    const unsigned int sr1[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650}; // NEC 202807F
    const unsigned int sr2[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 20240BF
    const unsigned int sr3[67] = {8950, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 1600, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 202C03F
    const unsigned int sr4[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650}; // NEC 20220DF
    const unsigned int sr5[67] = {8950, 4300, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 1600, 650, 450, 650, 1600, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 202A05F
    const unsigned int sr6[67] = {8900, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 202609F
    const unsigned int sr7[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650}; // NEC 202E01F
    const unsigned int sr8[67] = {8950, 4350, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 1600, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 20210EF
    const unsigned int sr9[67] = {8900, 4350, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 1600, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 1600, 600, 500, 600, 1600, 600, 1600, 650, 1600, 600, 1600, 650}; // NEC 202906F
    const unsigned int sr0[67] = {8950, 4300, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 20200FF
    const unsigned int srDisplay[67] = {8950, 4300, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 1600, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 1550, 650, 500, 600, 1600, 650}; // NEC 202A25D
    const unsigned int srClear[67] = {8950, 4350, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 1600, 600, 500, 600, 1600, 650, 1600, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 500, 650, 450, 600, 1600, 650, 1600, 600, 1600, 650}; // NEC 202B847
    const unsigned int srPUp[67] = {8900, 4350, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 1600, 650, 450, 650, 1600, 600, 1600, 650, 1600, 600, 1600, 600, 500, 650, 1600, 600}; // NEC 20242BD
    const unsigned int srPDown[67] = {8950, 4350, 650, 450, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 20258A7
    const unsigned int srExit[67] = {8900, 4350, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650, 450, 650, 1550, 650}; // NEC 20202FD
    const unsigned int srBack[67] = {8900, 4350, 650, 450, 650, 450, 650, 450, 600, 500, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 600, 1600, 650, 500, 600, 1600, 600, 500, 650, 450, 600, 500, 600, 500, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 1600, 600, 1650, 600, 1600, 600, 1600, 650, 1600, 600, 500, 650, 1550, 650}; // NEC 202827D
    const unsigned int srUp[67] = {8950, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 1600, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 600, 1600, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 202D02F
    const unsigned int srDown[67] = {8950, 4300, 650, 450, 650, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1550, 650, 500, 600, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 202708F
    const unsigned int srLeft[67] = {8950, 4350, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600, 1600, 600, 500, 600, 1600, 650, 1600, 600, 1600, 650}; // NEC 20208F7
    const unsigned int srRight[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 2028877
    const unsigned int srOK[67] = {8900, 4350, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 600, 500, 650, 450, 650, 1600, 600, 500, 650, 1550, 650, 450, 650, 1600, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650}; // NEC 202B04F
    const unsigned int srPPlus[67] = {8950, 4350, 600, 500, 600, 500, 650, 450, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 202A857
    const unsigned int srPMinus[67] = {8900, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 600, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 20238C7
    const unsigned int srVPlus[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 1550, 650, 1600, 600, 1600, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 202F807
    const unsigned int srVMinus[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1600, 600, 1600, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650}; // NEC 2027887
    const unsigned int srRed[67] = {8950, 4350, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 600, 500, 600, 500, 600, 500, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 2026897
    const unsigned int srGreen[67] = {8900, 4350, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 550, 550, 1650, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 600, 500, 600, 1600, 600, 1650, 600, 1600, 650, 450, 650, 1600, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1600, 650, 500, 600, 1600, 650, 1550, 650, 1600, 650}; // NEC 202E817
    const unsigned int srBlue[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 700, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 1600, 650, 1550, 650, 450, 650, 450, 650, 1600, 650, 1550, 650, 1600, 650}; // NEC 20218E7
    const unsigned int srYellow[67] = {8950, 4300, 650, 450, 650, 450, 700, 400, 650, 450, 650, 450, 700, 400, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 700, 400, 700, 400, 650, 1600, 650, 450, 650, 1550, 650, 450, 650, 450, 700, 1550, 650, 1550, 650, 450, 700, 400, 700, 400, 650, 450, 650, 1600, 650, 1550, 650, 450, 700, 400, 650, 1600, 650, 1550, 650, 1600, 600}; // NEC 2029867
    const unsigned int srMenu[67] = {8950, 4300, 650, 450, 700, 400, 650, 500, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 700, 400, 700, 400, 650, 450, 700, 400, 700, 450, 600, 500, 600, 1600, 650, 450, 650, 450, 700, 1550, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 450, 700, 400, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 1600, 650}; // NEC 20248B7
    const unsigned int srRev[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 700, 400, 700, 400, 700, 1550, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 1550, 650, 1600, 600, 500, 600, 500, 650, 1550, 650, 450, 650, 450, 650, 450, 700, 400, 650, 450, 650, 1600, 650, 1550, 700, 400, 700, 1550, 650, 1550, 650, 1600, 600}; // NEC 202C837
    const unsigned int srFwd[67] = {8900, 4350, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 650, 1550, 650, 1550, 650, 450, 650, 1600, 650, 1550, 650, 450, 650, 450, 650, 500, 600, 500, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 202D827
    const unsigned int srPlay[67] = {9000, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 500, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 500, 600, 500, 600, 1600, 650, 450, 650, 1550, 650, 450, 650, 500, 600, 500, 650, 1550, 650, 1550, 650, 450, 700, 1550, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650}; // NEC 20228D7
    const unsigned int srStop[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 500, 650, 450, 650, 450, 650, 1550, 650, 450, 700, 400, 650, 450, 700, 1550, 650, 450, 650, 1550, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 450, 650, 1600, 600}; // NEC 20222DD
    const unsigned int srSubtitle[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 650, 500, 650, 450, 600, 500, 600, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 650, 450, 650, 500, 600, 500, 600, 1600, 650, 450, 650, 1600, 600, 1600, 650, 450, 650, 450, 650, 1550, 650, 450, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 1600, 600, 1600, 650, 450, 650, 1550, 650, 450, 650, 1600, 650}; // NEC 202CA35
    const unsigned int srAudio[67] = {8900, 4350, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1650, 550, 550, 600, 1600, 600, 1650, 550, 550, 600, 1600, 600, 1600, 600, 500, 600, 1650, 550, 550, 600, 500, 600, 500, 600, 1650, 550, 550, 550, 550, 550, 1650, 600, 500, 600, 1650, 550}; // NEC 202DA25
    const unsigned int srRec[67] = {8950, 4300, 650, 450, 650, 450, 650, 450, 700, 400, 700, 400, 700, 450, 650, 1550, 650, 450, 650, 450, 700, 400, 700, 400, 700, 400, 700, 400, 700, 400, 700, 1550, 650, 450, 650, 1550, 700, 1550, 650, 1550, 650, 450, 700, 1550, 600, 500, 650, 1550, 650, 450, 700, 400, 700, 400, 700, 400, 650, 1600, 650, 450, 650, 1550, 650, 450, 700, 1550, 650}; // NEC 202EA15
    const unsigned int srGoto[67] = {8950, 4300, 700, 400, 700, 400, 700, 450, 650, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 700, 400, 700, 400, 700, 400, 700, 450, 650, 450, 650, 450, 650, 1550, 650, 450, 700, 400, 700, 400, 700, 1550, 650, 450, 650, 1550, 700, 400, 700, 1550, 650, 450, 650, 1550, 700, 1550, 650, 450, 650, 1550, 650, 450, 650, 1550, 700, 450, 650, 1550, 650}; // NEC 2022AD5
    
    // TV
    #define tPower 0xE0E040BF
    #define tPowerS 0xE0E007F8
    #define tSource 0xE0E0807F
    #define t1 0xE0E020DF
    #define t2 0xE0E0A05F
    #define t3 0xE0E0609F
    #define t4 0xE0E010EF
    #define t5 0xFFFFFFFF
    #define t6 0xE0E050AF
    #define t7 0xE0E030CF
    #define t8 0xE0E0B04F
    #define t9 0xE0E0708F
    #define t0 0xE0E08877
    #define tTTX 0xE0E034CB
    #define tPRECH 0xE0E0C837
    #define tMute 0xE0E0F00F
    #define tVUp 0xE0E0E01F
    #define tVDown 0xE0E0D02F
    #define tPUp 0xE0E048B7
    #define tPDown 0xE0E008F7
    #define tCHlist 0xE0E0D629
    #define tMenu 0xE0E058A7
    #define tSmart 0xE0E09E61
    #define tGuide 0xE0E0F20D
    #define tTools 0xE0E0D22D
    #define tInfo 0xE0E0F807
    #define tUp 0xE0E006F9
    #define tDown 0xE0E08679
    #define tLeft 0xE0E0A659
    #define tRight 0xE0E046B9
    #define tOK 0xE0E016E9
    #define tReturn 0xE0E01AE5
    #define tExit 0xE0E0B44B
    #define tRed 0xE0E036C9
    #define tGreen 0xE0E028D7
    #define tYellow 0xE0E0A857
    #define tBlue 0xE0E06897
    #define tRev 0xE0E0A25D
    #define tFwd 0xE0E012ED
    #define tPause 0xE0E052AD
    #define tPlay 0xE0E0E21D
    #define tRec 0xE0E0926D
    #define tStop 0xE0E0629D
    
    // Definice IR
    IRrecv irrecv(RECV_PIN);
    IRsend irsend;
    decode_results results;
    
    // Proměnné
    
    void setup()
    {
      Serial.begin(9600);
      irrecv.enableIRIn(); // Start the receiver
    }
    
    void loop() {
    
      // Rozpoznání přijatého kódu
      if (irrecv.decode(&results)) {
        Serial.print("Prijato: ");
        Serial.println(results.value, HEX);
    
        delay(100); // Zpožděné odeslání
        switch (results.value) {
          case tRed:
            irsend.sendRaw(srRed, 67, 38);
            break;
          case tGreen:
            irsend.sendRaw(srGreen, 67, 38);
            break;
          case tYellow:
            irsend.sendRaw(srYellow, 67, 38);
            break;
          case tBlue:
            irsend.sendRaw(srBlue, 67, 38);
            break;
          case tUp:
            irsend.sendRaw(srUp, 67, 38);
            break;
          case tDown:
            irsend.sendRaw(srDown, 67, 38);
            break;
          case tLeft:
            irsend.sendRaw(srLeft, 67, 38);
            break;
          case tRight:
            irsend.sendRaw(srRight, 67, 38);
            break;
          case tOK:
            irsend.sendRaw(srOK, 67, 38);
            break;
          case t1:
            irsend.sendRaw(sr1, 67, 38);
            break;
          case t2:
            irsend.sendRaw(sr2, 67, 38);
            break;
          case t3:
            irsend.sendRaw(sr3, 67, 38);
            break;
          case t4:
            irsend.sendRaw(sr4, 67, 38);
            break;
          case t5:
            irsend.sendRaw(sr5, 67, 38);
            break;
          case t6:
            irsend.sendRaw(sr6, 67, 38);
            break;
          case t7:
            irsend.sendRaw(sr7, 67, 38);
            break;
          case t8:
            irsend.sendRaw(sr8, 67, 38);
            break;
          case t9:
            irsend.sendRaw(sr9, 67, 38);
            break;
          case t0:
            irsend.sendRaw(sr0, 67, 38);
            break;
          case tPUp:
            irsend.sendRaw(srPUp, 67, 38);
            break;
          case tPDown:
            irsend.sendRaw(srPDown, 67, 38);
            break;
          case tPlay:
            irsend.sendRaw(srPlay, 67, 38);
            break;
          case tPause:
            irsend.sendRaw(srPlay, 67, 38);
            break;
          case tStop:
            irsend.sendRaw(srStop, 67, 38);
            break;
          case tRev:
            irsend.sendRaw(srRev, 67, 38);
            break;
          case tFwd:
            irsend.sendRaw(srFwd, 67, 38);
            break;
          case tRec:
            irsend.sendRaw(srRec, 67, 38);
            break;
        }
        irrecv.enableIRIn();
        irrecv.resume(); // Receive the next value
      }
    }
    

    Neřekl bych, že je tam toho moc? Trochu to nechápu. U každého case jsem měl Serial.println(„Nejaky text“); po odstranění těchto debug informací se velikost globálních proměnných snížila, ale nevím jak to snížit dále?

    odpověď na: IR ovladač #6852
    mitch
    Účastník

    Tak máš asi nejspíš pravdu… Problém je, že ten STB má asi nějakou extrémně citlivou přijímací diodu takže budu muset vymyslet dokonalé odstínění abych ověřil tuto teorii, ale dle zběžných pokusů to tak asi je 🙂

    odpověď na: NodeMCU v1.0 a INPUT_PULLUP #6732
    mitch
    Účastník

    Hmm tak indukce nebo nevím se projevuje i u tohoto zapojení 🙁 tzn, že budu muset asi spínat relátko a tím na krátko spínat vstup do MCU

Aktuálně je na stránce zobrazeno 8 příspěvků - 1. až 8. (celkem z 8)