element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Need help for IR remote control
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 5 replies
  • Subscribers 393 subscribers
  • Views 940 views
  • Users 0 members are here
Related

Need help for IR remote control

Former Member
Former Member over 11 years ago

for eg. this is a code for switching leds on off with ir remote

 

 

in this when i press Forward button led light up

when i press Reverse button led1 light up

and when any thing else is pressed all go off

it act as a on off switch

i have to press some thing to turn led off

but i want it to act as a push button when Reverse button is pressed it light up and as soon as i release the reverse button it should go off

i tried to use while statment but using that nothing happen

on youtube there are many who have made ir cars but they press one buton to move it and again some other button to stop it

 

#include <IRremote.h>

 

 

int IR_Recv = 3;   //IR Receiver Pin 3

int led = 9;

int led1 = 10; 

int led2 = 11;

int led3 = 12;

 

 

IRrecv irrecv(IR_Recv);

decode_results results;

 

 

void setup(){

  Serial.begin(9600);  //starts serial communication

  irrecv.enableIRIn(); // Starts the receiver

  pinMode(led, OUTPUT);      // sets the digital pin as output

  pinMode(led1, OUTPUT);      // sets the digital pin as output

  pinMode(led2, OUTPUT);      // sets the digital pin as output

  pinMode(led3, OUTPUT);      // sets the digital pin as output

}

 

 

void loop(){

  //decodes the infrared input

  if (irrecv.decode(&results)){

    long int decCode = results.value;

    Serial.println(decCode);

   //switch case to use the selected remote control button

   switch (results.value){

      case 16722135: //when you press the Forward button

    

       digitalWrite(led,HIGH);

       digitalWrite(led1,LOW);

       digitalWrite(led2,LOW);

       digitalWrite(led3,LOW);

       break;

      

      case 16754775: //when you press the Reverse button

        digitalWrite(led1,HIGH);

        digitalWrite(led2,LOW);

        digitalWrite(led3,LOW);

        digitalWrite(led,LOW);

        break;

      

      case 16730295: //when you press the Mute button

           digitalWrite(led2,HIGH);

           digitalWrite(led3,LOW);

           digitalWrite(led1,LOW);

           digitalWrite(led,LOW);

        break;

      

      case 16724175: //when you press the Power button

          digitalWrite(led3,HIGH);  

          digitalWrite(led2,LOW);

          digitalWrite(led1,LOW);

          digitalWrite(led,LOW); 

      default:

      {

        digitalWrite(led,LOW);

        digitalWrite(led1,LOW);

        digitalWrite(led2,LOW);

        digitalWrite(led3,LOW);

      } 

  }

    irrecv.resume(); // Receives the next value from the button you press

  }

 

}

  • Sign in to reply
  • Cancel
Parents
  • nschreiber0813
    0 nschreiber0813 over 11 years ago

    Dear: Rajat

    If you are looking for how to use an Ir sensor look here because the code is pretty good so why don't you try it https://learn.adafruit.com/tmp36-temperature-sensor/overview.

    From: Noah

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to nschreiber0813

    Actually Noah, while good advise re temperature sensors, in this case slightly off topic, what Rajat is asking about is an Infrared remote Control like you use on your TV, not an infrared thermometer or temperature sensor. A good link if that where so but does not answer his immediate question.

     

    Regards

     

    Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to nschreiber0813

    Actually Noah, while good advise re temperature sensors, in this case slightly off topic, what Rajat is asking about is an Infrared remote Control like you use on your TV, not an infrared thermometer or temperature sensor. A good link if that where so but does not answer his immediate question.

     

    Regards

     

    Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube