21.12.14

A successful way to control infrared equipment via an Arduino and an infrared LED

Controlling and LED-stripe with IR light
This is the second part of my little tutorial on how to measure an IR pulse sequence from a remote control (see this article) and then copy and send this sequence to control equipment like a TV, a lamp or other IR equipment. The adarfuit.com website gives us once more a possible way on how to implement this, but in the following article we want to discuss on how to make it easier and again somehow more convenient in many cases. We can easily use the comma-separated values we got from our pulse measurements from the previous article to control the LED and output the needed 38 kHz signal sequence.

Again, first the code, and afterwards an explanation:

int irledpin=7;
int pulsmatrix[200]=        { // in the next line we put our pulse sequence, starting with the time of our first pulse:
8990,4540,530,560,510,640,500,590,580,560,520,580,550,580,580,550,520,580,560,1720,520,1780,510,1660,550,1710,530,1710,560,1690,550,1720,530,1720,580,1650,560,570,570,620,480,1770,520,560,520,580,550,640,490,580,530,640,490,1710,530,1720,550,580,530,1720,550,1690,550,1710,540,1710,560,40030,8980,2240,530              
                            };
long matrixsum[200];             


void setup()                                                               {
  pinMode(irledpin, OUTPUT); Serial.begin(9600);
  matrixsum[0]=pulsmatrix[0];
  for(int i=1;i<200;i++){matrixsum[i]=pulsmatrix[i]+matrixsum[i-1];}       }   // The values are added, what we get is the ending times in microseconds for pulses and pulse-free times.


void pulse()                        {
    digitalWrite(irledpin, HIGH);
    delayMicroseconds(9);         // the value can be 10 or 8 also, but 9 should work quite well as it gives us a pulse very near to 38 kHz.
    digitalWrite(irledpin, LOW);
    delayMicroseconds(9);           }
   

void loop(){

  delay(1000);              // delay between pulses, may not be too little, at best stay over 300.
  Serial.println("Pulse sequence starts");
  long start=micros();
  for(int i=0;i<200;i+=1)                                     {
    while(micros()<start+matrixsum[i]){pulse();}                  // here we send our 38 kHz pulse
    i+=1;
    while(micros()<start+matrixsum[i]){}                      }   // a pause, until we start our next pulse 
  Serial.println("done");
  Serial.println(); 
 
 }
 

In the following a little explanation:

The code is easy to understand. We define our pulse sequence at the beginning, where the first time is the length of the first pulse, the next value is the pulse-free time, then the next pulse value and so on. The matrixsum adds all the values in some kind of a ladder, so we have the ending times of the pulses in a very accurate way. That avoids a problematic stretching of the whole sequence and was very accurate in first tests - see the hi-res video on Youtube shown below:


In this video the Arduino sends the command to change the color to red every 1 second, and in between I switch to other colors with the "real" remote.

You can download the program as .ino file here.

12 Kommentare:

  1. Ik vond het geweldig. Dank je wel voor het delen.
    Grafisch Ontwerpers Reclamebureau Nexoz gebruikt verschillende methoden om werken te maken, die allemaal lid zijn van de Nederlandse Vereniging van Grafisch Ontwerpers.

    Wij mensen houden van schoonheid en orde. Een aantrekkelijke website met unieke graphics heeft een enorme impact op uw publiek.

    AntwortenLöschen
  2. Dieser Kommentar wurde vom Autor entfernt.

    AntwortenLöschen
  3. بسیار لذت بردیم. و مطالبتون مثل همیشه فوق العاده است.

    آژانس مارکتینگ آرکا گروهی متشکل از افراد متخصص می باشد که با به کارگیری دانش بازاریابی دیجیتال و تمرکز بر روی تولید محتوای دیجیتال,مسیر رشد کسب وکار شما را به بهترین شکل طراحی می کند.

    AntwortenLöschen
  4. Dieser Kommentar wurde vom Autor entfernt.

    AntwortenLöschen
  5. تعمیر لوازم خانگی توسط یک تیم مکانیک حرفه ای در دو سوت تعمیر با حدود 15 سال تجربه انجام می شود. ما ماشین لباسشویی ، ماشین ظرفشویی ، خشک کن ، یخچال و فریزر را تعمیر می کند.

    دو سوت تعمیر تقریباً در همه جا در تهران کار می کند، بنابراین با این تیم تعمیراتی در تماس باشید. زیرا می توانند برای تعمیر لوازم خانگی به خانه شما بیایند.

    https://2sottamir.ir/

    AntwortenLöschen
  6. شرکت ساخت لوگو در تهران و کرج

    AntwortenLöschen
  7. طراحی آرم و لوگو بخشی از فرآیند برندسازی شرکت ها و مجموعه ها است.

    بیش از 70 درصد تبلیغات برندینگ بر روی آرم های تجاری انجام می شود.

    برای داشتن تبلیغات موثر و کارآمد، کسب و کار شما نیاز به یک لوگوی حرفه ای دارد.

    ممکن است چندین شرکت در ایران وجود داشته باشند که به صورت حرفه ای تمامی خدمات برندینگ را ارائه می دهند.

    از این رو شرکت برندینگ حرفه ای ریوال آنلاین می تواند خدمات مختلف را به عنوان خدمات حرفه ای طراحی لوگو به شما ارائه دهد.

    AntwortenLöschen
  8. ساخت لوگو با بیان خلاقانه مفهوم برند، تعامل مشتری را تضمین می کند

    ایجاد لوگوی خلاقانه برند شما را مجبور می کند تا بدون زحمت و با پنهان کردن مفهوم برند در لایه های طراحی لوگو و رنگ ها، از دیگران پیشی بگیرد.

    در نتیجه مخاطب با نشستن در ضمیر ناخودآگاه می تواند درآمد خود را تامین کند.

    AntwortenLöschen
  9. لوگو چهره کسب و کار شما است و تقریبا اولین عامل در شناسایی برند شما با مشتریان بالقوه است.

    AntwortenLöschen
  10. فروشگاه استوت یک فروشگاه آنلاین ایرانی است که در سال 1401 تاسیس شد. این فروشگاه در زمینه فروش محصولات متنوعی از جمله سوپرمارکت، لوازم خانگی، دیجیتال، پوشاک، لوازم آرایشی و بهداشتی و غیره فعالیت می کند. فروشگاه استوت با ارائه طیف گسترده ای از محصولات و خدمات با کیفیت، توانسته است رضایت مشتریان زیادی را جلب کند.
    https://stoat.ir/

    AntwortenLöschen

Kommentare verfassen ist hier sehr einfach, man kann sogar ohne Anmeldung anonym Kommentare hinterlassen. Also, zeig' uns deine Meinung ...

Kontakt

Name

E-Mail *

Nachricht *

Haftungsausschluss

disclaimer