Hi to everyone. I know this have been posted before, but can't find a solution.
I have a proyect where I control a RGB via bluetooth Serial adapter. Now I want to add IR support, but when I add the line irrecv.enableIRIn() I start getting wrong values in the serial monitor. I'm running arduino UNO.
I'm using SoftwareSerial:
#define Rx 11 //This could be: 8,9,10,11,14 (MISO), 15 (SCK), 16 (MOSI).
#define Tx 2
#include <SoftwareSerial.h>
SoftwareSerial BT(Rx,Tx);
I've tried different pins, and also try modifying the IRremoteInt.h... but not sure which one to use, I'm running arduino UNo atmega328p, but can't find that on the library, this one?
// Teensy 2.0
#elif defined(__AVR_ATmega32U4__)
#define IR_USE_TIMER1 // tx = pin 14
//#define IR_USE_TIMER3 // tx = pin 9
//#define IR_USE_TIMER4_HS // tx = pin 10
i've tried with the three timers and still getting problems ![]()
At first I thought it was a problem with PWM but then I realize the serial is going wrong.
Any idea?
Thank you very much!
This is the serial code:
void leerDatos2()
{
if(BT.available() > 0)
Serial.println(BT.read());
}
void leerDatos()
{
if(BT.available() > 0)
{
char x = BT.read();
if (x == '>') {
readInProgress = false;
newDataFromPC = true;
inputBuffer[bytesRecvd] = 0;
parseData();
}
if(readInProgress)
{
inputBuffer[bytesRecvd] = x;
bytesRecvd ++;
if (bytesRecvd == buffSize) {
bytesRecvd = buffSize - 1;
}
}
if (x == '<')
{
bytesRecvd = 0;
readInProgress = true;
}
}
}
void parseData()
{
char * strtokIndx;
byte aux=0, aux1=0;
strtokIndx = strtok(inputBuffer,", (");
aux1 = atoi(strtokIndx);
opcion(aux1);
strtokIndx = strtok(NULL, ", (");
aux = atoi(strtokIndx);
if(aux!=200)
dato1 = aux;
strtokIndx = strtok(NULL, ", ");
aux = atoi(strtokIndx);
if(aux!=200)
dato2 = aux;
strtokIndx = strtok(NULL, ", ");
aux = atoi(strtokIndx);
if(aux!=200)
dato3 = aux;
strtokIndx = strtok(NULL,", )");
aux = atoi(strtokIndx);
if(aux!=200 && aux1>=1 && aux1<=8)
dato4 = aux;
mostrarDatos();
}
void mostrarDatos()
{
Serial.print("<");
Serial.print(opLed);
Serial.print(", ");
Serial.print(dato1);
Serial.print(", ");
Serial.print(dato2);
Serial.print(", ");
Serial.print(dato3);
Serial.print(", ");
Serial.print(dato4);
Serial.println(">");
}