Working with Remote

Import:

#include <IRremote.h>
const int RECV_PIN=2;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define IR_USE_TIMER2

variable:
long g;

setup:
irrecv.enableIRIn();

check input: //
if(irrecv.decode(&results))
g = results.value;

restart: // put in the end of functuin
irrecv.resume();// Restart the ISR state machine and Receive the next value

g code:

g == 16593103 // 0
1 // g == 16582903
g == 16615543 //2
g == 16599223 //3
g == 16591063 // 4
g == 16623703 //5

Do you have a question?

Code tags?

If its look fine?

conectivity

It makes no sense at all.

Would it be easier to ask your question in another language? There are sections in this forum for different languages.

No.

What version of the IRremote library are you using? That code is written for an older version of the code than is currently the latest version.

The IRremote GitHub page shows how to convert the older code to work with the new version of the library. And the examples show how to use the new version.

Here is a simple example remote reader using the latest library version.

#include <IRremote.hpp>

const byte IR_RECEIVE_PIN = 4; //

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

   Serial.println("IR receive test");
   IrReceiver.begin(IR_RECEIVE_PIN);
}

void loop()
{
   if (IrReceiver.decode())
   {
      //ignore repeats
      if ((IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT))
      {
         IrReceiver.resume();
         return;
      }      
      unsigned long keycode = IrReceiver.decodedIRData.command;      
      Serial.print("command = ");
      Serial.println(keycode);
      Serial.print("address = ");
      Serial.println(IrReceiver.decodedIRData.address);
      Serial.print("raw data = ");
      Serial.println(IrReceiver.decodedIRData.decodedRawData);
      Serial.println();
      
      IrReceiver.resume();
   }
}

The command is the unique code for each key.
The address is the identifier for the particular remote or remote function (TV, DVD, ... ).
And raw is the raw data that includes the command and address.

Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

You can go back and fix your original post by highlighting the code and clicking the </> in the menu bar.
code tags new

איפוס מוניטור:

Serial.begin(9600);

המרת ערכים:
precent_Value = map(var, x, y, 0 , 100)

זמן נוכחי:
current_time = millis()

שימוש בשלט:

צריך לייבא:

#include <IRremote.h>
const int RECV_PIN=2;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define IR_USE_TIMER2

משתנה מסוג:

long g;

בשלב: ה - Setup:
irrecv.enableIRIn();

שימוש בפונקציה - קלט:

if(irrecv.decode(&results))
g = results.value;

בסוף הפונקציה איפוס:

irrecv.resume();// Restart the ISR state machine and Receive the next value

המרה של הערכים:

g == 16593103 // 0
1 // g == 16582903
g == 16615543 //2
g == 16599223 //3
g == 16591063 // 4
g == 16623703 //5

חיבור:

שימוש בServo :

צריך לייבא:

#include <Servo.h>

Servo myservo;

ב - Setup:

myservo.attach(9);

שימוש בפונקציה:

void turnFan(){
if(turnRight){
angle = angle + 15;
myservo.write(angle);
delay(20);
if(angle >= 180){
turnRight = false;
}
}
else{
angle = angle - 15;
myservo.write(angle);
delay(20);
if(angle <= 0){
turnRight = true;
}
}
}

שימוש ב User Input:

המתנה עד קבלת Input רצוי:

char userInput(){
while(Serial.available() == 0 and (Serial.read() != 'input1' and Serial.read() != 'input2')){
delay(300);
}
return Serial.read();
}

קבלת Input מסויים:

char userInput2(){
return Serial.read();
}

שימוש באזעקה:

חיבור PWN עם נגד + || - GND
pinMode(alarmPin,OUTPUT);

//turns on and off alarm
void alarm(){
digitalWrite(alarmPin, HIGH);
delay(t +Add );
digitalWrite(alarmPin, LOW);
delay(t + Add );
Add = add + 5;
}

אני לא מאמין שיש פורום בעברית

please use English in the general forum and do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).

Similar question here: Working with Remote With answers.

Same as in your other post. You are using code written for an older version of the IRremote library. What version are you using?

@ayelet7235

Your two topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.