Sending the Signals4

Embed Size (px)

Citation preview

  • 7/30/2019 Sending the Signals4

    1/5

    Step 4: Sending the Signals

    Now once you have the codes that you want, and have uploaded the program with the signal you want

    to send, all you have to do is hook up the IR LED to pin 13 and then to ground similar to the schematic

    in the picture. You don't need the resistor if you have a Duemilanove Arduino because it has a built in

    resistor for PIN 13 so you don't have to worry.

    This can also be done with an ATTINY 8 pin microcontroller to cut down on size. I have one but I'm not

    sure how to use it yet.

    Now I will be showing you a real-world example on how to do this.

    AGAIN, THIS IS NOT MY CODE, I just copied and pasted to make it easier to understand.

    So I got this code when I pressed the channel up button on my Comcast remote. This is the kind of

    remote that you will have if you have the small black boxes that use the small black remotes. They act

    as an analog to digital converter box that only can change channels.

    Here is the Serial Monitor code:

    Received:

    OFF ON

    36328 usec, 280 usec

    820 usec, 300 usec

    1580 usec, 320 usec

    640 usec, 240 usec

    2740 usec, 240 usec

    1280 usec, 240 usec

    1240 usec, 240 usec

    1120 usec, 240 usec

    2600 usec, 240 usec

    12740 usec, 240 usec

    840 usec, 240 usec

    980 usec, 240 usec

    700 usec, 240 usec

    700 usec, 240 usec

    720 usec, 240 usec

    2460 usec, 260 usec

    (/files/deriv/FUC/KT35/GVP28W2Z/FUCKT35GVP28W2Z.LARGE.jpg)

    About This Instructable

    Posted:

    Dec 3, 2011

    License:

    13,849 views

    26 favorites

    (/member/Wally_Z/)

    Wally_Z

    (/member/Wally_Z/)

    My Youtube

    (http://www.youtube.com/user/wj

    Follow

    I like to tinker with electronics. I like to

    mod, hack, and learn how something works by

    taking it apart.

    11

    Bio:

    (/id/Giant-USB-Flash-Drive)

    (/id/Arduino-Police-Lights-

    ATMega-2650-Version)

    (/id/How-to-make-Arduino-

    Police-Lights)

    More by Wally_Z

    Tags:

    (/)

    let's make

    share what you make >

    (/about/submit.jsp))

    Explore (/tag/type-id/) Create (/about/submit.jsp) Contests (/contest/) Community (/community/) Login (/you/)

    http://www.instructables.com/files/deriv/FUC/KT35/GVP28W2Z/FUCKT35GVP28W2Z.LARGE.jpghttp://www.instructables.com/http://www.instructables.com/tag/type-id/http://www.instructables.com/about/submit.jsphttp://www.instructables.com/contest/http://www.instructables.com/community/http://www.instructables.com/you/http://googleads.g.doubleclick.net/aclk?sa=L&ai=CEVNl6nFnUZ3kIYTKsQfAs4DIAfax-KADAAAQASDopqUDUK_izLgHYM3w7oCsA8gBAuACAKgDAcgDnQSqBMABT9CxWdwn_60IUc8N86kXoMAZst-25IcAVjspMtHaYFvi_lsKRxTkxBmWC7_nijumCWgo3-MDkEjpmJuTwQb1Ue-APzIFQGl_XUOqc7si5rMf7j7bgq7Kj8huN77ZxdnwHnmNWXAkhSXAXCCjQ1nLblEUcRpt_PSHWUWA-vl1XMrxyxKuOONWZrjhlqRmNTGvk7bD1g9lqEnoOZLz9ndqBMmNwggzGhpIpDYESOKkCWIMPUmbiCLBYEhXwDwzKMQl4AQBoAYU&num=0&sig=AOD64_0ZAslYf2xwY1jUc6qhDzGQl0bLIQ&client=ca-pub-1783560022203827&adurl=http://www.instructables.com/contest/indestructibles/http://www.instructables.com/you/http://www.instructables.com/community/http://www.instructables.com/contest/http://www.instructables.com/about/submit.jsphttp://www.instructables.com/tag/type-id/http://www.instructables.com/http://www.instructables.com/group/techshop/http://www.instructables.com/group/familyhandyman/http://www.instructables.com/group/123d/http://www.instructables.com/about/submit.jsphttp://www.instructables.com/http://www.instructables.com/id/How-to-make-Arduino-Police-Lightshttp://www.instructables.com/id/Arduino-Police-Lights-ATMega-2650-Versionhttp://www.instructables.com/id/Giant-USB-Flash-Drivehttp://www.youtube.com/user/wjz10595http://www.instructables.com/member/Wally_Z/http://www.instructables.com/member/Wally_Z/http://www.instructables.com/id/How-to-control-your-TV-with-an-Arduino/step4/Sending-the-Signals/#statsModalhttp://www.googleadservices.com/pagead/aclk?sa=L&ai=CfxkQ6nFnUZfUIvDGsQeMmoD4A5uk0qcDu-mYlh7c2R4QASDopqUDUNDhxtoDYM3w7oCsA6ABr8_E_gPIAQLgAgCoAwHIA50EqgTJAU_QNO1FPO6nRIx7CDxo7_omNsxgIAF863oE7rhBmaicyFN3hG9yf5oygjPETSTtJk9KSGFxFIc5F_gziuAfYvIA-_tP8f2M2TqvSZf9_APga2ve1OEtDfzi7Tggy994YGPGNsscWVBb7L3TRSLOrqDIxq7-rYJih8V6ojhKdMqYtJXeslqIhofkLbqHw13oo8RBS1USpOPyYW3xEupOKbWWPAkDknxjizINDOJjKR0IGuCtCehg6fPc-OgTLpxRVbkcNBAcfYzrqeAEAYgGAaAGAoAHubC7AQ&num=1&cid=5GhqAnmYKkrEt0kh3gTVlS23&sig=AOD64_12qSdYsMWrG2t2GcC7uvC2w6EJnw&client=ca-pub-1783560022203827&adurl=http://www.tekscan.com/flexiforce/force-transducer.htmlhttp://www.instructables.com/files/deriv/FUC/KT35/GVP28W2Z/FUCKT35GVP28W2Z.LARGE.jpghttp://googleads.g.doubleclick.net/aclk?sa=L&ai=CEVNl6nFnUZ3kIYTKsQfAs4DIAfax-KADAAAQASDopqUDUK_izLgHYM3w7oCsA8gBAuACAKgDAcgDnQSqBMABT9CxWdwn_60IUc8N86kXoMAZst-25IcAVjspMtHaYFvi_lsKRxTkxBmWC7_nijumCWgo3-MDkEjpmJuTwQb1Ue-APzIFQGl_XUOqc7si5rMf7j7bgq7Kj8huN77ZxdnwHnmNWXAkhSXAXCCjQ1nLblEUcRpt_PSHWUWA-vl1XMrxyxKuOONWZrjhlqRmNTGvk7bD1g9lqEnoOZLz9ndqBMmNwggzGhpIpDYESOKkCWIMPUmbiCLBYEhXwDwzKMQl4AQBoAYU&num=0&sig=AOD64_0ZAslYf2xwY1jUc6qhDzGQl0bLIQ&client=ca-pub-1783560022203827&adurl=http://www.instructables.com/contest/indestructibles/
  • 7/30/2019 Sending the Signals4

    2/5

    700 usec, 240 usec

    700 usec, 240 usec

    14904 usec, 260 usec

    820 usec, 240 usec

    1660 usec, 240 usec

    700 usec, 260 usec

    2740 usec, 240 usec

    1240 usec, 240 usec

    1260 usec, 240 usec

    1100 usec, 240 usec

    2620 usec, 240 usec

    12720 usec, 260 usec

    840 usec, 220 usec

    2080 usec, 240 usec1780 usec, 260 usec

    700 usec, 240 usec

    700 usec, 240 usec

    2480 usec, 240 usec

    700 usec, 240 usec

    700 usec, 240 usec

    Here is the code that I made from the raw data by putting the code in:

    // This sketch will change the channel every ten seconds so you can be doing other things

    //while watching tv and not having to change the channel, like being on a laptop and having

    //it cycle through the channels so you have free hands.

    //We all know pressing a button is so hard, so why not make it automated?

    int IRledPin = 13; // LED connected to digital pin 13

    // The setup() method runs once, when the sketch starts

    void setup() {

    // initialize the IR digital pin as an output:

    pinMode(IRledPin, OUTPUT);

    Serial.begin(9600);

    }

    void loop()

    {

    SendChannelUpCode();

    delay(20*1000); // wait twenty seconds (20 seconds * 1000 milliseconds) Change this value fordifferent intervals.

    }

    // This procedure sends a 38KHz pulse to the IRledPin

    // for a certain # of microseconds. We'll use this whenever we need to send codes

    void pulseIR(long microsecs) {

    // we'll count down from the number of microseconds we are told to wait

    cli(); // this turns off any background interrupts

    while (microsecs > 0) {

    // 38 kHz is about 13 microseconds high and 13 microseconds low

    digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen

    delayMicroseconds(10); // hang out for 10 microseconds

    digitalWrite(IRledPin, LOW); // this also takes about 3 microsecondsdelayMicroseconds(10); // hang out for 10 microseconds

    // so 26 microseconds altogether

    microsecs -= 26;

    }

    sei(); // this turns them back on

    }

    void SendChannelUpCode() {

    // This is the code for the CHANNEL + for the TV COMCAST

    delayMicroseconds(36328); //Time off (LEFT column)

    pulseIR(280); //Time on (RIGHT column)

  • 7/30/2019 Sending the Signals4

    3/5

    delayMicroseconds(1240);

    pulseIR(240);

    delayMicroseconds(1120);

    pulseIR(240);

    delayMicroseconds(2600);

    pulseIR(240);

    delayMicroseconds(12740);

    pulseIR(240);

    delayMicroseconds(840);

    pulseIR(240);

    delayMicroseconds(980);

    pulseIR(240);

    delayMicroseconds(700);

    pulseIR(240);delayMicroseconds(700);

    pulseIR(240);

    delayMicroseconds(720);

    pulseIR(240);

    delayMicroseconds(2460);

    pulseIR(240);

    delayMicroseconds(700);

    pulseIR(240);

    delayMicroseconds(700);

    pulseIR(240);

    delayMicroseconds(14904);

    pulseIR(240);

    delayMicroseconds(820);

    pulseIR(240);

    delayMicroseconds(1600);

    pulseIR(240);

    delayMicroseconds(700);

    pulseIR(260);

    delayMicroseconds(2740);

    pulseIR(240);

    delayMicroseconds(1240);

    pulseIR(240);

    delayMicroseconds(1260);

    pulseIR(240);

    delayMicroseconds(1100);

    pulseIR(240);

    delayMicroseconds(2620);

    pulseIR(240);

    delayMicroseconds(12720);pulseIR(260);

    delayMicroseconds(840);

    pulseIR(220);

    delayMicroseconds(2080);

    pulseIR(240);

    delayMicroseconds(1780);

    pulseIR(260);

    delayMicroseconds(700);

    pulseIR(240);

    delayMicroseconds(700);

    pulseIR(240);

    delayMicroseconds(2480);

    pulseIR(240);

    delayMicroseconds(700);

    pulseIR(240);delayMicroseconds(700);

    pulseIR(240);

    }

    Remove these ads by Signing Up (/account/gopro?sourcea=removeads&nxtPgName=Sending+the+Signals&nxtPg=/id/How -to-

    control-your-TV-w ith-an-Arduino/step4/Sending-the-Signals/)

    How to control your TV with an Arduino! by Wally_Z (/member/Wally_Z/)

    Download (/id/How-to-control-your-TV-with-an-Arduino/?download=pdf) See All (/id/How-to-control-your-TV-with-an-Arduino/?ALLSTEPS)

    (/id/How-to-control-your-TV-with-an-Arduino/step3/Interpreting-the-Signals/) Jump To 4 Steps

    Favorite

    http://www.instructables.com/id/How-to-control-your-TV-with-an-Arduino/step3/Interpreting-the-Signals/http://www.instructables.com/id/How-to-control-your-TV-with-an-Arduino/?ALLSTEPShttp://www.instructables.com/id/How-to-control-your-TV-with-an-Arduino/?download=pdfhttp://www.instructables.com/member/Wally_Z/http://www.googleadservices.com/pagead/aclk?sa=L&ai=CC2XH6nFnUZrWIoG7sQez3YDIBMyL-p4EzIjTlm7AjbcBEAEg6KalA1DqgdcYYM3w7oCsA6AB1NqF0QPIAQLgAgCoAwHIA50EqgTQAU_Qn-7McLxntAXHCABrQ3E_91kQZ3nbUGrZoxxwmC1NlXJtkESp-r1gWxj_q51TWRmGZJusT2JR0koA737aO5Bp3zlmfloOKU6JqwtMv_n5fmq0ZZJjkz5esmwaNBToK3tLBlN7U2lj3P3a5L_Hag1o7Lil4HCqWMkhgHz7T6pS6EEcybybE1tqq5XrBgBr-3a8Yc4-YLHO_rZD6lpzAVRWPIfqs0inHxoztX0SX655jdeeSWp7EtTf-FGBJqvoR9OZVpE7EnKyd80i3lLfAU7gBAGIBgGgBgKAB5Sl-i4&num=1&cid=5GiTsmr7uzGBXj_thFEJpNM4&sig=AOD64_0rr-BLND40QzVFmupFy7451SeNwg&client=ca-pub-1783560022203827&adurl=http://www.miniinthebox.com/led-light-bulbs_c3115%3Flitb_from%3Dpaid_adwords_display%26adword_mt%3D%26adword_ct%3D29542846076%26adword_kw%3Dhome%2520led%2520lighting%26adword_pos%3Dnone%26adword_pl%3Dwww.instructables.com%26adword_net%3Dd%26adword_tar%3D&nm=1http://www.googleadservices.com/pagead/aclk?sa=L&ai=CIDem6nFnUbTlIpCtsQez44HoA7mj5JUDodvjijfAjbcBEAEg6KalA1CrhLaABWDN8O6ArAOgAYHktf4DyAEC4AIAqAMByAOdBKoEywFP0BSN0PsCRWEocJLB8yYFTDxk-YmTGWLohGlJsk8nYeLugvFxEm81x9-mBCh_iCQNObIHpkikPAlWE3DL3fH5eLiySj2-dv4TPagzM4Q6Ik4bv0ASVB_uwROcre7t5Fts_BUtxgWosL7uXBeih6Q09vKq0PhGon4pcI3a2CUI55Kb8iJ75-7vwWQt0finqaaJM28xk-HOC8S97nDrFrQXCH0FgzppGKJD_WNgtkZNEjQr-JNOgsXwGGGHZI7V7Uzkj33QNtWR_0zqNOAEAYgGAaAGAoAH55vKAQ&num=1&cid=5GhV5PdOn_-fnOrsCOzBDTQQ&sig=AOD64_125GF74s4VMuBGRqvLGwVCT48GxA&client=ca-pub-1783560022203827&adurl=http://PIDTuning.net/learn-pid-control.htmlhttp://www.instructables.com/account/gopro?sourcea=removeads&nxtPgName=Sending+the+Signals&nxtPg=/id/How-to-control-your-TV-with-an-Arduino/step4/Sending-the-Signals/
  • 7/30/2019 Sending the Signals4

    4/5

    Previous (/id/How-to-control-your-TV-with-an-Arduino/step3/Interpreting-the-Signals/)

    Post Comment

    (/member/c1c2c3/)

    Oct 7, 2012. 3:01 AM Reply (CYV54J4H7UQJLDX)

    5

    (/member/Wally_Z/)

    Dec 5, 2012. 9:01 AM Reply (CO9LXFZHABC7WK2)

    (/member/jabujavi/)

    Jun 24, 2012. 7:22 AM Reply (CMK9D74H3QFJC35)

    (/member/carlos.camposalcocer/)

    Jul 18, 2012. 7:26 PM Reply (C564I1MH4I7VYE8)

    (/member/jabujavi/)

    Jul 19, 2012. 1:30 AM Reply (CFV7CLCH4AGKNKM)

    (/member/wmain/)

    May 1, 2012. 8:50 PM Reply (CUP2YVGH1PISXEP)

    c1c2c3 (/member/c1c2c3/) says:

    Do you need a resistor to go to the IR led?

    Wally_Z (/member/Wa lly_Z/) (author) says:Not if you hook the IR LED up to pin

    13. Pin 13 on MOST arduino's

    already has a resistor on it. If you're

    not sure if it has a resistor, you

    should use a 100ohm just to be

    safe.

    jabujavi (/member/jabuja vi/) says:

    I have a questions.

    hy use delayMicrosecond and don't simply delay? The value of delay is in ms, is not?

    carlos.camposalcocer (/member/carlos.camposalcocer/) says:

    ms=milliseconds

    us=microseconds

    jabujavi (/member/jabuja vi/) says:

    FAIL

    Thanks, I work with us many times

    and in this case didn't see it...

    wmain (/member/wmain/) says:

    You could define a typedef as

    ypedef struct i rCode {

    int off;

    int on;

    } codes[34];

    codes[0] = {36328, 280};

    .

    .

    .

    codes[33] = {700, 240};

    hen use this code to send it

    for (cx=0; cx

  • 7/30/2019 Sending the Signals4

    5/5

    About Us

    ho We Are (/about/)

    Advertise (/advertise/)

    Contact (/about/contact.jsp)

    obs (/community?categoryGroup=marketplace&category=jobs_internships)

    Help (/community?categoryGroup=Help)

    Find Us

    Facebook (http://www.facebook.com/instructables)

    Youtube (http://www.youtube.com/user/instructablestv)

    Twitter (http://www.twitter.com/instructables)

    Pinterest (http://www.pinterest.com/instructables)

    Resources

    or Teachers (/ teachers/)

    Artists in Residence (/group/air/)

    Sponsorships (/sponsorship/)

    orums (/community/)

    Answers (/tag/type-question/)

    Mobile

    Download our new apps for

    iOS and android!

    Android

    (https://play.google.com/store/apps/details?

    id=com.adsk.instructables)

    iOS

    (https://itunes.apple.com/app/instructables/id586765571)

    Visit Our Store (http://store.instructables.com/)

    Go Pro Today (/account/gopro?sourcea=footer)

    let's make(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)

    Terms of service (/tos.html) | Privacy Policy (http://usa.autodesk.com/privacy/) | Mobile Site (http://m.instructables.com)

    http://m.instructables.com/http://usa.autodesk.com/privacy/http://www.instructables.com/tos.htmlhttp://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112http://www.instructables.com/account/gopro?sourcea=footerhttp://store.instructables.com/https://itunes.apple.com/app/instructables/id586765571https://play.google.com/store/apps/details?id=com.adsk.instructableshttp://www.instructables.com/tag/type-question/http://www.instructables.com/community/http://www.instructables.com/sponsorship/http://www.instructables.com/group/air/http://www.instructables.com/teachers/http://www.pinterest.com/instructableshttp://www.twitter.com/instructableshttp://www.youtube.com/user/instructablestvhttp://www.facebook.com/instructableshttp://www.instructables.com/community?categoryGroup=Helphttp://www.instructables.com/community?categoryGroup=marketplace&category=jobs_internshipshttp://www.instructables.com/about/contact.jsphttp://www.instructables.com/advertise/http://www.instructables.com/about/