چه کسی فکرش را میکرد که تقریباً هر پیوست آردوینو را میتوان به طریقی با کنترل تلویزیون کنترل کرد؟ اکنون زمان آن است که بفهمیم چگونه.
![](https://www.instructables.com/static/defaultIMG/file.TINY.gif)
Arduino.skp 141 کیلوبایت
مرحله 1: راه اندازی و مواد
تنظیم برای این کاملاً اساسی است. چالش واقعی پیدا کردن محصولات منظم برای این کار و نوشتن کد است.
مواد.
1x Arduino
1x Servo در دسترس @ Hobbyking Sparkfun و غیره.
سیم های جامپر
1x دیود گیرنده مادون قرمز موجود @ Sparkfun Allelectronics Radioshack و غیره.
4x AA باتری و نگهدارنده Ebay ارزان ترین برای نگهدارنده است
1x تلویزیون از راه دور
هر چیزی که می خواهید کنترل کنید
برای نصب به طرح پیوست مراجعه کنید. اگر اسکچاپ ندارید می توانید آن را از اینجا دانلود کنید.
http://sketchup.google.com/intl/en/download/
مرحله 2: ارزش ها
اولین کاری که باید انجام دهید این است که کد زیر را روی آردوینو بارگذاری کنید و مانیتور سریال را باز کنید.
سپس دکمه ای را روی کنترل از راه دور که به سمت گیرنده است فشار دهید تا مقدار چاپ شده را ببینید. اولین مقداری را که می بینید نادیده بگیرید زیرا ممکن است خاموش باشد.
#include <IRremote.h>
int RECV_PIN = A0; // پین آنالوگ 0
IRrecv irecv(RECV_PIN);
نتایج decode_results.
void setup()
{
Serial.begin(9600);
irecv.enableIRIn(); // گیرنده را راه اندازی کنید
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // مقدار بعدی را دریافت کنید
}
}
مرحله 3: کد
اکنون که مقادیر هر دکمه را روی ریموت خود دارید، می توانید سروو را کنترل کنید. در زیر نیز کدی وجود دارد که می توانید بدون سروو انجام دهید و در عوض فقط LED را روی پین دیجیتال 13 کنترل کنید.
اگر قبلاً آن را ندارید، باید کتابخانه مادون قرمز را از http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html دانلود کنید.
ممکن است برخی از این کد را بشناسید، و آن ساده نگه داشتن همه چیز است. من از کدهایی استفاده می کنم که به طور گسترده در اینترنت در دسترس هستند و عمدتاً از arduino.cc و http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html. برای مرجع بیشتر
کد LED
برای جزئیات بیشتر: با استفاده از آردوینو، هر چیزی را از راه دور با سیگنال های مادون قرمز کنترل کنید
و غیره ]
در ادامه، متن انگلیسی این مطلب را میتوانید مشاهده نمایید:
![](https://www.instructables.com/static/defaultIMG/file.TINY.gif)
Arduino.skp141 KB
Step 1: Setup and Materials
The setup for this is quite basic. The real challenge is finding neat products for this and writing the code.
Materials.
1x Arduino
1x Servo available @ Hobbyking Sparkfun etc.
Jumper wires
1x Infrared receiver diode available @ Sparkfun Allelectronics Radioshack etc.
4x AA Battery and holder Ebay is the cheapest for the holder
1x TV remote
Anything that you want to control
See the attached sketchup for the setup. If you do not have sketchup you can download it here.
http://sketchup.google.com/intl/en/download/
Step 2: Values
The first thing to do is load the below code on to the arduino and open the serial monitor.
Next press a button on the remote aimed at the receiver to see the value printed. Ignore the first value that you see as it may by off.
#include <IRremote.h>
int RECV_PIN = A0; // Analog Pin 0
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
Step 3: Code
Now that you have the values for each button on your remote you can control the servo. Below is also code that you can do without a servo and instead just control the LED on digital pin 13.
You will need to download the infrared library from http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html if you do not have it already.
You may recognize some of this code, and that is to keep everything simple. I am using code widely available on the internet largely from arduino.cc and http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html so that if anyone has questions they can look it up for more reference.
LED code
1x Servo available @ Hobbyking Sparkfun etc.Jumper wires
1x Infrared receiver diode available @ Sparkfun Allelectronics Radioshack etc.
4x AA Battery and holder Ebay is the cheapest for the holder
1x TV remote
For more detail: Control anything remotely with Infrared signals using Arduino