Infra kezelése

Processing/Wiring (illetve C) nyelvű programozási fogások, tippek. (AVR-Duino, Arduino, EthDuino, Diecimila, Severino, Nano, LilyPad)
Avatar
Bagameri
DrótVégénSzéndarab
Hozzászólások: 37
Csatlakozott: 2013. március 15. péntek, 14:21

Infra kezelése

Hozzászólás Szerző: Bagameri »

Infra vörös témával kapcsolatban (nem akar menni ez a IRrecvDump program) be jelöltem hol áll a program ha valaki tud segítsen .

Kód: Egész kijelölése

/*
 * IRremote: IRrecvDump - dump details of IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
 */

#include <IRremote.h>

int RECV_PIN = 3;

IRrecv irrecv(RECV_PIN);  //Itt áll a program

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
//  decode_results *results = (decode_results *)v
void dump(decode_results *results) {
  int count = results->rawlen;
  if (results->decode_type == UNKNOWN) {
    Serial.print("Unknown encoding: ");
  } 
  else if (results->decode_type == NEC) {
    Serial.print("Decoded NEC: ");
  } 
  else if (results->decode_type == SONY) {
    Serial.print("Decoded SONY: ");
  } 
  else if (results->decode_type == RC5) {
    Serial.print("Decoded RC5: ");
  } 
  else if (results->decode_type == RC6) {
    Serial.print("Decoded RC6: ");
  }
  else if (results->decode_type == PANASONIC) {	
    Serial.print("Decoded PANASONIC - Address: ");
    Serial.print(results->panasonicAddress,HEX);
    Serial.print(" Value: ");
  }
  else if (results->decode_type == JVC) {
     Serial.print("Decoded JVC: ");
  }
  Serial.print(results->value, HEX);
  Serial.print(" (");
  Serial.print(results->bits, DEC);
  Serial.println(" bits)");
  Serial.print("Raw (");
  Serial.print(count, DEC);
  Serial.print("): ");

  for (int i = 0; i < count; i++) {
    if ((i % 2) == 1) {
      Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
    } 
    else {
      Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
    }
    Serial.print(" ");
  }
  Serial.println("");
}


void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    dump(&results);
    irrecv.resume(); // Receive the next value
  }
}
Avatar
Robert
Elektronbűvölő
Hozzászólások: 10191
Csatlakozott: 2005. december 9. péntek, 7:00

Re: Infra kezelése

Hozzászólás Szerző: Robert »

A gyári mintakód miért nem jó?
dlaszlo
DrótVégénSzéndarab
Hozzászólások: 49
Csatlakozott: 2013. április 20. szombat, 6:38

Re: Infra kezelése

Hozzászólás Szerző: dlaszlo »

Miből gondolod hogy ott megáll a program, ahol bejelölted? Az egy konstruktor hívás, ennyi van benne (ha jó változatot nézek):

Kód: Egész kijelölése

IRrecv::IRrecv(int recvpin)
{
  irparams.recvpin = recvpin;
  irparams.blinkflag = 0;
}
Avatar
Bagameri
DrótVégénSzéndarab
Hozzászólások: 37
Csatlakozott: 2013. március 15. péntek, 14:21

Re: Infra kezelése

Hozzászólás Szerző: Bagameri »

Azért áll meg a program állítólag ,mert valami hiányzik a függvénykönyvtárból.
Avatar
Robert
Elektronbűvölő
Hozzászólások: 10191
Csatlakozott: 2005. december 9. péntek, 7:00

Re: Infra kezelése

Hozzászólás Szerző: Robert »

Pl:
http://www.pjrc.com/teensy/td_libs_IRremote.html
http://www.righto.com/2009/08/multi-pro ... brary.html
https://learn.sparkfun.com/tutorials/ir ... cation/all

"To install, move the downloaded IRremote directory to:
arduino-1.x/libraries/IRremote
where arduino-1.x is your Arduino installation directory

After installation you should have files such as:
arduino-1.x/libraries/IRremote/IRremote.cpp"
Avatar
Bagameri
DrótVégénSzéndarab
Hozzászólások: 37
Csatlakozott: 2013. március 15. péntek, 14:21

Re: Infra kezelése

Hozzászólás Szerző: Bagameri »

Végre sikerült ,most már nem akad meg a program . Most már egy kérdésem van, melyik PIN-re van kötve az EXT1-en a vevő (IR) ?
Avatar
Robert
Elektronbűvölő
Hozzászólások: 10191
Csatlakozott: 2005. december 9. péntek, 7:00

Re: Infra kezelése

Hozzászólás Szerző: Robert »

D2 vagy D3.
Avatar
Bagameri
DrótVégénSzéndarab
Hozzászólások: 37
Csatlakozott: 2013. március 15. péntek, 14:21

Re: Infra kezelése

Hozzászólás Szerző: Bagameri »

D3 a jó .Köszönöm az infót !
Avatar
Bagameri
DrótVégénSzéndarab
Hozzászólások: 37
Csatlakozott: 2013. március 15. péntek, 14:21

Re: Infra kezelése

Hozzászólás Szerző: Bagameri »

Van egy nagyon jó program ,de szeretném ha az egyes gomb lenyomásával egy Led is felkapcsolna .

Kód: Egész kijelölése

#include <LiquidCrystal.h>

 #include <IRremote.h> // use the library for IR
int receiver = 3; // pin 1 of IR receiver to Arduino digital pin 3
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
LiquidCrystal lcd( 4,5,6,7,8,9);
void setup()
{
  lcd.begin(16, 2);
pinMode (13,OUTPUT);

  irrecv.enableIRIn(); // Start the receiver
}
void translateIR() // takes action based on IR code received

{
  switch(results.value)
  {
    case 0x76044FE2: lcd.print(" Egyes gomb   "); break;
    case 0x76044DE2: lcd.print(" Kettes gomb   "); break;
   
    default: lcd.print(" other button   ");
  }
  delay(1000);
  lcd.clear();
}
void loop()
{
  lcd.setCursor(0, 0);
  digitalWrite(13, HIGH);
  if (irrecv.decode(&results)) // már kaptunk egy infravörös jelet ?
  {
    translateIR();
    for (int z=0; z<2; z++) // figyelmen kívül hagyja a 2. és 3. jel ismételje
    {
      irrecv.resume(); // megkapja a következő értéket
    }
  }
}
Avatar
Robert
Elektronbűvölő
Hozzászólások: 10191
Csatlakozott: 2005. december 9. péntek, 7:00

Re: Infra kezelése

Hozzászólás Szerző: Robert »

A translateIR() függvényhez ahol az LCD-ket kezeli, ott az adott sorba írdd be....
Avatar
Bagameri
DrótVégénSzéndarab
Hozzászólások: 37
Csatlakozott: 2013. március 15. péntek, 14:21

Re: Infra kezelése

Hozzászólás Szerző: Bagameri »

Kösz a segítséget ,most már tudom a távirányítóval ki be kapcsolgatni amit szeretnék. :)
bgachip
DrótVégénSzéndarab
Hozzászólások: 49
Csatlakozott: 2013. november 5. kedd, 20:00

Re: Infra kezelése

Hozzászólás Szerző: bgachip »

Ez sem akar működni mint a ds1820.....

szóval ez is panelen van 2 smd leddel, világít mind a kettő.
sárga vcc-t mutatja
kék, vout-ot
felhúzó ellenállásnak 4,7 kohm-os ellenállást használok.

digital 11-es lábra bekötöttem a jelet.

feltöltés után, nyomom a távirányító be/ki kapcsoló gombját 0,5 cm-ről de semmi a soros porton. :(

https://learn.adafruit.com/ir-sensor/te ... -ir-sensor

Ez alapján kötöttem be, a felhúzó ellenállást 5v-ra húztam.

Kód: Egész kijelölése

/*
 * IRrecord: record and play back IR signals as a minimal 
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * An IR LED must be connected to the output PWM pin 3.
 * A button must be connected to the input BUTTON_PIN; this is the
 * send button.
 * A visible LED can be connected to STATUS_PIN to provide status.
 *
 * The logic is:
 * If the button is pressed, send the IR code.
 * If an IR code is received, record it.
 *
 * Version 0.11 September, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 11;
int BUTTON_PIN = 12;
int STATUS_PIN = 13;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(BUTTON_PIN, INPUT);
  pinMode(STATUS_PIN, OUTPUT);
}

// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state

// Stores the code for later playback
// Most of this code is just logging
void storeCode(decode_results *results) {
  codeType = results->decode_type;
  int count = results->rawlen;
  if (codeType == UNKNOWN) {
    Serial.println("Received unknown code, saving as raw");
    codeLen = results->rawlen - 1;
    // To store raw codes:
    // Drop first value (gap)
    // Convert from ticks to microseconds
    // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion
    for (int i = 1; i <= codeLen; i++) {
      if (i % 2) {
        // Mark
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
        Serial.print(" m");
      } 
      else {
        // Space
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
        Serial.print(" s");
      }
      Serial.print(rawCodes[i - 1], DEC);
    }
    Serial.println("");
  }
  else {
    if (codeType == NEC) {
      Serial.print("Received NEC: ");
      if (results->value == REPEAT) {
        // Don't record a NEC repeat value as that's useless.
        Serial.println("repeat; ignoring.");
        return;
      }
    } 
    else if (codeType == SONY) {
      Serial.print("Received SONY: ");
    } 
    else if (codeType == RC5) {
      Serial.print("Received RC5: ");
    } 
    else if (codeType == RC6) {
      Serial.print("Received RC6: ");
    } 
    else {
      Serial.print("Unexpected codeType ");
      Serial.print(codeType, DEC);
      Serial.println("");
    }
    Serial.println(results->value, HEX);
    codeValue = results->value;
    codeLen = results->bits;
  }
}

void sendCode(int repeat) {
  if (codeType == NEC) {
    if (repeat) {
      irsend.sendNEC(REPEAT, codeLen);
      Serial.println("Sent NEC repeat");
    } 
    else {
      irsend.sendNEC(codeValue, codeLen);
      Serial.print("Sent NEC ");
      Serial.println(codeValue, HEX);
    }
  } 
  else if (codeType == SONY) {
    irsend.sendSony(codeValue, codeLen);
    Serial.print("Sent Sony ");
    Serial.println(codeValue, HEX);
  } 
  else if (codeType == RC5 || codeType == RC6) {
    if (!repeat) {
      // Flip the toggle bit for a new button press
      toggle = 1 - toggle;
    }
    // Put the toggle bit into the code to send
    codeValue = codeValue & ~(1 << (codeLen - 1));
    codeValue = codeValue | (toggle << (codeLen - 1));
    if (codeType == RC5) {
      Serial.print("Sent RC5 ");
      Serial.println(codeValue, HEX);
      irsend.sendRC5(codeValue, codeLen);
    } 
    else {
      irsend.sendRC6(codeValue, codeLen);
      Serial.print("Sent RC6 ");
      Serial.println(codeValue, HEX);
    }
  } 
  else if (codeType == UNKNOWN /* i.e. raw */) {
    // Assume 38 KHz
    irsend.sendRaw(rawCodes, codeLen, 38);
    Serial.println("Sent raw");
  }
}

int lastButtonState;

void loop() {
  // If button pressed, send the code.
  int buttonState = digitalRead(BUTTON_PIN);
  if (lastButtonState == HIGH && buttonState == LOW) {
    Serial.println("Released");
    irrecv.enableIRIn(); // Re-enable receiver
  }

  if (buttonState) {
    Serial.println("Pressed, sending");
    digitalWrite(STATUS_PIN, HIGH);
    sendCode(lastButtonState == buttonState);
    digitalWrite(STATUS_PIN, LOW);
    delay(50); // Wait a bit between retransmissions
  } 
  else if (irrecv.decode(&results)) {
    digitalWrite(STATUS_PIN, HIGH);
    storeCode(&results);
    irrecv.resume(); // resume receiver
    digitalWrite(STATUS_PIN, LOW);
  }
  lastButtonState = buttonState;
}
Avatar
Robert
Elektronbűvölő
Hozzászólások: 10191
Csatlakozott: 2005. december 9. péntek, 7:00

Re: Infra kezelése

Hozzászólás Szerző: Robert »

Igaz nincs a kódban SPI busz? (SD, Ethernet), és a Hardware sem?
Tedd át a 2...8 lábakra.
bgachip
DrótVégénSzéndarab
Hozzászólások: 49
Csatlakozott: 2013. november 5. kedd, 20:00

Re: Infra kezelése

Hozzászólás Szerző: bgachip »

Sziasztok

Működik az infra vevő, de az adó nem...

Ezt kaptam...
Decoded NEC: 20DF10EF (32 bits)
Raw (68): 24840 8950 -4450 600 -550 550 -550 550 -1650 600 -550 550 -550 550 -550 550 -600 550 -550 550 -1600 600 -1650 600 -550 550 -1650

600 -1600 600 -1600 600 -1650 600 -1600 600 -550 600 -550 550 -550 550 -1650 550 -550 600 -550 550 -550 550 -550 550 -1650 600 -1600 600

-1650 600 -550 550 -1600 600 -1650 600 -1650 600 -1650 550

És ezt küldtem ki, de nem csinál semmi....

Kód: Egész kijelölése

/*
 * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

IRsend irsend;

void setup()
{
  Serial.begin(9600);
}

void loop() {
  if (Serial.read() != -1) {
    for (int i = 0; i < 3; i++) {
      irsend.sendNEC(0x20DF10EF, 32); // Sony TV power code
      delay(40);
    }
  }
}
a 3-as digit-re dugtam a jelet...
Valami ötlet?
Avatar
Robert
Elektronbűvölő
Hozzászólások: 10191
Csatlakozott: 2005. december 9. péntek, 7:00

Re: Infra kezelése

Hozzászólás Szerző: Robert »

Melyik lib-et használod? Valamelyik PWM kimeneten van az adójel. Hogy kötöd be az adóLED-et?
Válasz küldése