I'm studing Arduino and so far I've made a simple circuit that takes some values from a remote control via a IR Receiver (VS1838B) and depending on the key I pressed it lights an RGB led.
At this point I'd like to mix my knowledge and make a simple Android app that is able to do the same thing but I have found some problems.
This is the code:
irManager = (ConsumerIrManager) getSystemService(Context.CONSUMER_IR_SERVICE);
if(!irManager.hasIrEmitter())
Toast.makeText(this, "Non hai l'emettitore IR", Toast.LENGTH_LONG).show();
else
Toast.makeText(this, "Hai l'emettitore IR", Toast.LENGTH_LONG).show();
red.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendIR(new int[] {1,2,5,4,5,6,7,8,9,10,11,12,13,14});
}
});
}
public void sendIR(int[] message){
irManager.transmit(38000, message);
}
1) First of all I have no idea of what the second parameter of irManager.transmit() is. In Arduino if I Log all the message that the IR receiver get, it will print out only a integer number and not an interger array and I don't know how transform that int in a int array.
2) If open my serial monitor in Arduino and watch the logs, every time I click the "red" button the value passed to the IR Receive change and so most of the times even if the key is pressed the rgb led won't light.
How can I fix this ?
Check this tutorial:
http://devtrigger.blogspot.it/2014/05/android-infrared-ir-transmitter-code.html
This part of it should be enough: