Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pic18f2550 irremote blocks loop?
07-08-2017, 08:00 PM,
#1
pic18f2550 irremote blocks loop?
Hello, this is my code:
Code:
/*
* DecodeRemote: demonstrates decoding IR codes from a remote control
* An IR detector/demodulator must be connected to the input IRSENSOR.
* Version 0.1 March, 2014
* Author : Regis Blanchot
*/

#define IRSENSOR 13 // pin 0, can be any digital pin

char brand[][10] = {"UNKNOWN", "NEC", "SONY", "RC5", "RC6", "DISH", "SHARP", "PANASONIC", "JVC", "SANYO", "MITSUBISHI"};

decode_results results; // Results returned from the decoder

volatile int outputlevel[3];
volatile int level;

void setup()
{
Serial.begin(9600);
Serial.print("HELLO ");
outputlevel[0] = 50;
outputlevel[1] = 80;
outputlevel[2] = 20;
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
IRremote.enableIRIn(IRSENSOR); // Start the receiver
IRremote.blink(true); // Built-in led will blink at reception
}

void loop()
{
if (IRremote.decode(&results)==DECODED)
{
if (results.decode_type>10)
results.decode_type = 0;

Serial.print("Decoded ");
Serial.printNumber(results.value, DEC);
Serial.print(" (type ");
Serial.print(brand[results.decode_type]);
Serial.print(")\r\n");

/// or

//Serial.printf("Decoded %ld (type %s)\r\n", results.value, brand[results.decode_type]);

IRremote.resume(); // Ready to receive the next value
}
level++;
if (level>99)
level=0;
PORTBbits.RB0=level<outputlevel[0];
PORTBbits.RB1=level<outputlevel[1];
PORTBbits.RB2=level<outputlevel[1];

}

but the RB0, RB1, RB2 diodes blinks once only when some IR Remote signal is received... do you have any ideas how to fix it? I tried interrupt but they seem to conflict with IrRmeote.
Reply
09-08-2017, 02:57 PM,
#2
RE: pic18f2550 irremote blocks loop?
(07-08-2017, 08:00 PM)PIC18F47J53 Wrote: Hello, this is my code:
Code:
/*
* DecodeRemote: demonstrates decoding IR codes from a remote control
* An IR detector/demodulator must be connected to the input IRSENSOR.
* Version 0.1 March, 2014
* Author : Regis Blanchot
*/

#define IRSENSOR 13 // pin 0, can be any digital pin

char brand[][10] = {"UNKNOWN", "NEC", "SONY", "RC5", "RC6", "DISH", "SHARP", "PANASONIC", "JVC", "SANYO", "MITSUBISHI"};

decode_results results; // Results returned from the decoder

volatile int outputlevel[3];
volatile int level;

void setup()
{
Serial.begin(9600);
Serial.print("HELLO ");
outputlevel[0] = 50;
outputlevel[1] = 80;
outputlevel[2] = 20;
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
IRremote.enableIRIn(IRSENSOR); // Start the receiver
IRremote.blink(true); // Built-in led will blink at reception
}

void loop()
{
if (IRremote.decode(&results)==DECODED)
{
if (results.decode_type>10)
results.decode_type = 0;

Serial.print("Decoded ");
Serial.printNumber(results.value, DEC);
Serial.print(" (type ");
Serial.print(brand[results.decode_type]);
Serial.print(")\r\n");

/// or

//Serial.printf("Decoded %ld (type %s)\r\n", results.value, brand[results.decode_type]);

IRremote.resume(); // Ready to receive the next value
}
level++;
if (level>99)
level=0;
PORTBbits.RB0=level<outputlevel[0];
PORTBbits.RB1=level<outputlevel[1];
PORTBbits.RB2=level<outputlevel[1];

}

but the RB0, RB1, RB2 diodes blinks once only when some IR Remote signal is received... do you have any ideas how to fix it? I tried interrupt but they seem to conflict with IrRmeote.
I will look at this tonight.
fred
Reply
10-08-2017, 01:47 AM,
#3
RE: pic18f2550 irremote blocks loop?
(09-08-2017, 02:57 PM)derf158 Wrote:
(07-08-2017, 08:00 PM)PIC18F47J53 Wrote: Hello, this is my code:
Code:
/*
* DecodeRemote: demonstrates decoding IR codes from a remote control
* An IR detector/demodulator must be connected to the input IRSENSOR.
* Version 0.1 March, 2014
* Author : Regis Blanchot
*/

#define IRSENSOR 13 // pin 0, can be any digital pin

char brand[][10] = {"UNKNOWN", "NEC", "SONY", "RC5", "RC6", "DISH", "SHARP", "PANASONIC", "JVC", "SANYO", "MITSUBISHI"};

decode_results results; // Results returned from the decoder

volatile int outputlevel[3];
volatile int level;

void setup()
{
Serial.begin(9600);
Serial.print("HELLO ");
outputlevel[0] = 50;
outputlevel[1] = 80;
outputlevel[2] = 20;
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
toggle(USERLED); // alternate ON and OFF
delay(500); // wait for 1 sec
IRremote.enableIRIn(IRSENSOR); // Start the receiver
IRremote.blink(true); // Built-in led will blink at reception
}

void loop()
{
if (IRremote.decode(&results)==DECODED)
{
if (results.decode_type>10)
results.decode_type = 0;

Serial.print("Decoded ");
Serial.printNumber(results.value, DEC);
Serial.print(" (type ");
Serial.print(brand[results.decode_type]);
Serial.print(")\r\n");

/// or

//Serial.printf("Decoded %ld (type %s)\r\n", results.value, brand[results.decode_type]);

IRremote.resume(); // Ready to receive the next value
}
level++;
if (level>99)
level=0;
PORTBbits.RB0=level<outputlevel[0];
PORTBbits.RB1=level<outputlevel[1];
PORTBbits.RB2=level<outputlevel[1];

}

but the RB0, RB1, RB2 diodes blinks once only when some IR Remote signal is received... do you have any ideas how to fix it? I tried interrupt but they seem to conflict with IrRmeote.
I will look at this tonight.
fred

what are you trying to do?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)