-
• #2
This something I have done recently, check out the thread
http://forum.espruino.com/conversations/297428/#comment13372893The code below should get you started, you need to set the raw timings in the times array, this is the time in milliseconds the IR led will pulse on and off for. The timings can be worked out from the hex codes or try this website to find your device http://irdb.tk/
Also if you want to convert hex to raw times this thread helped me http://www.remotecentral.com/cgi-bin/mboard/everything_else/thread.cgi?325
Also note that the in built IR doesn't have much range, maybe 50cm at most.
var times = []; // on button press setWatch(function(e) { Puck.IR(times); }, BTN, { repeat: true, edge: 'rising', debounce: 50 });
-
• #3
I did a video about this on friday too: http://www.espruino.com/Puck.js+Infrared
If you can find the sequence of pulses needed for your TV online then yes, you really can just put the times in millisecond, separated by commas, into the
[]
in @MattC's code above (times for on, then off, then on, then off, etc).@MattC that irdb website looks excellent. I can't seem to find and easy way on there to get the raw numbers, but that other post you found seems to explain it pretty well.
I guess it should be pretty easy to make a little library that could take the pronto hex codes and send them directly?
-
• #4
@Gordon on the irdb website once you pick your device there are tabs for Pronto Hex, Hex and Raw codes (which you probably saw) but for some reason not all codes on the site have raw times, my LG tv luckily had the raw times but for a sony TV they were blank so I had to calculate them from the pronto codes.
There seems to be a few Arduino libraries which can send pronto hex codes, perhaps these could be converted for Espruino.
-
• #5
Yeah, unfortunately the TVs I looked up (samsung + panasonic) didn't have the raw times in :(
Yes, it should be pretty straightforward - it looks like even something as simple as
code.split(" ").map(x=>parseInt(x,16))
will get you halfway there -
• #6
Thank you to both of you. I will try. Hope that I will understand it :).
-
• #7
Just post up if you have any questions.
I haven't had a chance to try this out, but if you upload this function to the Puck:
function pronto(d) { var a=d.trim().split(" ").map(x=>parseInt(x,16)); var freq = 4145146/a[1]; Puck.IR(a.slice(4).map(x=>1000*x/freq)); }
Then you should be able to use 'Pronto Hex' codes. For instance for the LG power button.
You could use the codes off of http://irdb.tk/find/ and could do:
pronto("0000 006C 0022 0002 015B 00AD 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 06FB 015B 0057 0016 0E6C");
Or you could just run this code in a browser window on your PC:
function fromPronto(d) { var a=d.trim().split(" ").map(x=>parseInt(x,16)); var freq = 4145146/a[1]; console.log(a.slice(4).map(x=>(1000*x/freq).toFixed(1)).toString()); }
and it'll give you the numbers you need to put into
Puck.IR
-
• #8
Just to add - if someone can confirm this works for them then I'll write it up and stick it on the main Espruino website.
-
• #10
Ok, thanks! If you could post the error up it'd be handy.
-
• #12
Great - thanks!
-
• #13
I've now added a module to handle this, and some explanation: http://www.espruino.com/pronto
-
• #14
I see on the page there is UAI hex which is an even shorter string... does this encode the same info?
Sorry this link I cut and paste does not work :-(
http://irdb.tk/codes/#hexa -
• #15
I have no idea - you'd have to Google it. If it does then a PR with a UAI decoder would be great :)
Hello
I'm so new to this Puck Js. I just want to make first program just try to turn off TV or Air-Con.
Where should I start ?
Do I really need the IR receiver ? Or I can use hex code from the website and maybe there is a way to turn into values which can be used in Puck js.
Please advise me,
Thank you.