Hi all, i am trying to build a IR remote control using Attiny85 and controlled by Bluetooth (Android phone). I had tried build with Arduino Uno and Bluetooth (HC-05) and able to get the result i wanted. Now i want to make it smaller (and cheaper ) by using Attiny85 and BT HC-05. I used my Uno as programmer and successful to send and receive data from Attiny85 (using both HC-05 and Arduino Serial Monitor). But when i include IRremote library in my sketch, i was unable to send and receive all the data (using Arduino Serial Monitor). Below is my sketch.
#include <SoftwareSerial.h>
#include <IRremote.h>
const int Rx = 3; // this is physical pin 2
const int Tx = 4; // this is physical pin 3
SoftwareSerial mySerial(Rx, Tx);
char junk;
String inputString="";
int OFF = 0; //toggle for TV On Off
IRsend irsend;
void setup()
{
pinMode(2, OUTPUT);
pinMode(Rx, INPUT);
pinMode(Tx, OUTPUT);
mySerial.begin(9600);
mySerial.println("Ready");
}
void loop()
{
if(mySerial.available())
{
while(mySerial.available())
{
delay(3);
char inChar = (char)mySerial.read(); //read the input
inputString += inChar; //make a string of the characters coming on serial
}
mySerial.println(inputString);
mySerial.println(OFF);
while (mySerial.available() > 0)
{ junk = mySerial.read() ; } // clear the serial buffer
if(inputString =="01")
{
if(OFF == 0)
{
irsend.sendRC6(0x1000C,20);
digitalWrite(2,HIGH);
mySerial.println("LED ON");
}
else
{
irsend.sendRC6(0xC,20);
digitalWrite(2,LOW);
mySerial.println("LED OFF");
}
OFF = 1 - OFF;
}
inputString = ""; //clear inputString
}
}
For above sketch, i only able to get 0 as return for whatever character i sent via Serial Monitor to Attiny85.
But when i delete all IRremote library related lines, the sketch work properly. LED On and i get result as below.
01
0
LED ON
01
1
LED OFF
02
0
i am using Arduino 1.6.11, latest IRremote lib, latest ATtiny Core.
Is that IRremote conflict with SoftwareSerial when uploaded to Attiny85? Or my sketch have problem when using IRremote lib? i am newbie in electronic and programming.
Thanks for helps. Appreciate