Am cautat pe net si am dat exista articolul numit Infrared (IR) Remote, unde gasim destule date sa facem un prim test, mai ales ca ne prezinta receptorul de infrarosu.
In interiorul articolului este era un capitolas chiar despre acest model de telecomanda "car mp3", incluzand si un sketch:
/* YourDuino.com Example Software Sketch
IR Remote Kit Test
Uses YourDuino.com IR Infrared Remote Control Kit 2
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=153
based on code by Ken Shirriff - http://arcfn.com
Get Library at: https://github.com/shirriff/Arduino-IRremote
Unzip folder into Libraries. RENAME folder IRremote
terry@yourduino.com */
/*-----( Import needed libraries )-----*/
#include "IRremote.h"
/*-----( Declare Constants )-----*/
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
/*-----( Declare objects )-----*/
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
/*-----( Declare Variables )-----*/
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600);
Serial.println("IR Receiver Raw Data + Button Decode Test");
irrecv.enableIRIn(); // Start the receiver
}/*--(end setup )---*/
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
// Serial.println(results.value, HEX); UN Comment to see raw values
translateIR();
irrecv.resume(); // receive the next value
}
}/* --(end main loop )-- */
/*-----( Declare User-written Functions )-----*/
void translateIR() // takes action based on IR code received
// describing Car MP3 IR codes
{
switch(results.value)
{
case 0xFFA25D:
Serial.println(" CH- ");
break;
case 0xFF629D:
Serial.println(" CH ");
break;
case 0xFFE21D:
Serial.println(" CH+ ");
break;
case 0xFF22DD:
Serial.println(" PREV ");
break;
case 0xFF02FD:
Serial.println(" NEXT ");
break;
case 0xFFC23D:
Serial.println(" PLAY/PAUSE ");
break;
case 0xFFE01F:
Serial.println(" VOL- ");
break;
case 0xFFA857:
Serial.println(" VOL+ ");
break;
case 0xFF906F:
Serial.println(" EQ ");
break;
case 0xFF6897:
Serial.println(" 0 ");
break;
case 0xFF9867:
Serial.println(" 100+ ");
break;
case 0xFFB04F:
Serial.println(" 200+ ");
break;
case 0xFF30CF:
Serial.println(" 1 ");
break;
case 0xFF18E7:
Serial.println(" 2 ");
break;
case 0xFF7A85:
Serial.println(" 3 ");
break;
case 0xFF10EF:
Serial.println(" 4 ");
break;
case 0xFF38C7:
Serial.println(" 5 ");
break;
case 0xFF5AA5:
Serial.println(" 6 ");
break;
case 0xFF42BD:
Serial.println(" 7 ");
break;
case 0xFF4AB5:
Serial.println(" 8 ");
break;
case 0xFF52AD:
Serial.println(" 9 ");
break;
default:
Serial.println(" other button ");
}
delay(500);
} //END translateIR
/* ( THE END ) */
Pe ecran am obtinut:
Am apelat si la alt articol, numit IRremote Library de pe http://www.pjrc.com/, unde ma gasit un alt sketch simplu, care identifica tipul de codare.
Acest sketch este:
#include <IRremote.h>
const int RECV_PIN = 6;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
Pe ecran am obtinut:Se observa ca apare tipul ca fiind NEC si, pe langa codurile receptionate corect, apar si erori "FFFFFFFF", mai ales daca tin apasat un buton mai mult, deci sunt sanse mari sa fie de vina bateria, pe care am achizitionat-o separat:
Montajul arata asa:
Am modificat sketch-ul, cu senzorul de infrarosu la pinul 11, iar la pinii 6, 9 si 5 sunt conectate LED-urile rosu, verde si albastru dintr-un LED multicolor (RGB) cu catod comun prin rezistente de 180, 100, respectiv 100 ohmi.
Schema este:
- apas 0, se sting toate LED-urile indiferent de starea anterioara;
- apas 1, se aprinde LER-ul albastru la maxim;
- apas 2, se aprinde LED-ul verde la maxim;
- apas 3, se aprinde LED-ul rosu la maxim;
- apas 4, se aprinde LED-ul albastru la jumatate;
- apas 5, se aprinde LED-ul verde la jumatate;
- apas 6, se aprinde LED-ul rosu la jumatate;
- apas 7, se stinge LED-ul albastru;
- apas 8, se stinge LED-ul verde;
- apas 9, se stinge LED-ul rosu.
Sketch-ul este:
/* adapted sketch by niq_ro from http://www.tehnic.go.ro
and http://nicuflorica.blogspot.com/
/* YourDuino.com Example Software Sketch
IR Remote Kit Test
Uses YourDuino.com IR Infrared Remote Control Kit 2
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=153
based on code by Ken Shirriff - http://arcfn.com
Get Library at: https://github.com/shirriff/Arduino-IRremote
Unzip folder into Libraries. RENAME folder IRremote
terry@yourduino.com */
/*-----( Import needed libraries )-----*/
#include "IRremote.h"
/*-----( Declare Constants )-----*/
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
/*-----( Declare objects )-----*/
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
/*-----( Declare Variables )-----*/
// other
int ledr = 6; //pin for red LED
int leda = 5; //pin for blue LED
int ledv = 9; //pin for green LED
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600);
Serial.println("IR Receiver Raw Data + Button Decode Test");
Serial.println("0 = all off");
Serial.println("1 = blue LED is 100%");
Serial.println("2 = green LED is 100%");
Serial.println("3 = red LED is 100%");
Serial.println("4 = blue LED is 50%");
Serial.println("5 = green LED is 50%");
Serial.println("6 = red LED is 50%");
Serial.println("7 = blue LED is off");
Serial.println("8 = green LED is off");
Serial.println("9 = red LED is off");
Serial.println("---------------------------------------------");
irrecv.enableIRIn(); // Start the receiver
// initial state for LEds
analogWrite(ledr, 0);
analogWrite(leda, 0);
analogWrite(ledv, 0);
}/*--(end setup )---*/
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
// Serial.println(results.value, HEX); UN Comment to see raw values
translateIR();
irrecv.resume(); // receive the next value
}
}/* --(end main loop )-- */
/*-----( Declare User-written Functions )-----*/
void translateIR() // takes action based on IR code received
// describing Car MP3 IR codes
{
switch(results.value)
{
case 0xFFA25D:
Serial.println(" CH- ");
break;
case 0xFF629D:
Serial.println(" CH ");
break;
case 0xFFE21D:
Serial.println(" CH+ ");
break;
case 0xFF22DD:
Serial.println(" PREV ");
break;
case 0xFF02FD:
Serial.println(" NEXT ");
break;
case 0xFFC23D:
Serial.println(" PLAY/PAUSE ");
break;
case 0xFFE01F:
Serial.println(" VOL- ");
break;
case 0xFFA857:
Serial.println(" VOL+ ");
break;
case 0xFF906F:
Serial.println(" EQ ");
break;
case 0xFF6897:
{
Serial.println(" 0 ");
analogWrite(ledr, 0);
analogWrite(leda, 0);
analogWrite(ledv, 0);
}
break;
case 0xFF9867:
Serial.println(" 100+ ");
break;
case 0xFFB04F:
Serial.println(" 200+ ");
break;
case 0xFF30CF:
{
Serial.println(" 1 ");
analogWrite(leda, 255);
}
break;
case 0xFF18E7:
{
Serial.println(" 2 ");
analogWrite(ledv, 255);
}
break;
case 0xFF7A85:
{
Serial.println(" 3 ");
analogWrite(ledr, 255);
}
break;
case 0xFF10EF:
{
Serial.println(" 4 ");
analogWrite(leda, 122);
}
break;
case 0xFF38C7:
{
Serial.println(" 5 ");
analogWrite(ledv, 122);
}
break;
case 0xFF5AA5:
{
Serial.println(" 6 ");
analogWrite(ledr, 122);
}
break;
case 0xFF42BD:
{
Serial.println(" 7 ");
analogWrite(leda, 0);
}
break;
case 0xFF4AB5:
{
Serial.println(" 8 ");
analogWrite(ledv, 0);
}
break;
case 0xFF52AD:
{
Serial.println(" 9 ");
analogWrite(ledr, 0);
}
break;
default:
Serial.println(" other button ");
}
delay(500);
} //END translateIR
/* ( THE END ) */
Din pacate, bateria achizionata a fost consumata/veche, asa ca si-a dat duhul: .. asa ca o sa revin cu testele si un filmulet cand o sa iau alta baterie !
PS: Dupa o pauza, si-a mai revenit bateria si am putut sa fac 2 filmulete:
- aprinderea unui led multicolor cu o telecomanda de mp3 player
Salut. Am nevoie de un cod pentru receptorul de infrarosu ce tine aprins ledul(urile) atata timp cat tin apasat butonul telecomenzii iar cand eliberez butonul, ledul sa se stinga. Multumesc anticipat.
RăspundețiȘtergerela ultimul sketch.. la sfarsitul buclei principale stingi toate ledurile si ar trebui sa ai exact ce vrei tu pentru 3 leduri
ȘtergereMultam fain pentru rapiditate dar nu prea ma descurc in ale codarii asa ca mi-ar fi de mare folos un cod gata scris. Imi trebuie pentru o telecomanda care va comanda independent 3 motorase in ambele sensuri in functie de tasta de pe telecomanda apasata(deja ma cam depaseste).
RăspundețiȘtergereSALUT!!O SA INTRU DIRECT IN SUBIECT ,AM VREO SANSA SA GASESC UN CIRCUIT CU TELECOMANDA ,PTR AUTO ,NU MAI MERGE INCCHIDEREA CENTRALIZATA ,DAR AM UN BUTON BLOCARE USI CARE FUNCTIONEAZA PERFECT..ZIC CA AS PUTEA SA.L FOLOSESC ,,SA MA LEG CUMVA DE EL ,,SI CU TELECOMANDA SA INCHID SI SA DESCHID USILE,,AM VAZUT CATEVA PE NET DAR AU UN CIRCUIT SIMPLU INCHIS/DESCHIS ..MULTUMESC ANTICIPAT..SI DACA SE MERITA SA MA COMPLIC IN FELUL ASTA...
RăspundețiȘtergeresalut... in general proiectele astea unicat ies mai scumpe decat ceva industrial.. exista deschidere centralizata cu telecomanda si o poti conecta la actuatorul usii soferului... sau alarma cu comanda pentru inchidere centralizata, ea se leaga cum eprezentat in articolul de la http://www.tehnic.go.ro/auto.htm ... dar o cautare cu goagale te ducea si la preturi: https://inchidere-centralizata.compari.ro/
Ștergere