Commit e14f0c9b authored by Chris Young's avatar Chris Young

Version 1.42 add support for Pinoccio Scout

Supports ATmega256RFR2 processor used by Pinoccio Scout Arduino-like
boards. Includes sample sketches and a simple web app the HTML and
parent fdac2d02
Change Log for IRLib – an Arduino library for infrared encoding and decoding
Copyright 2013-2014 by Chris Young
Version 1.42 May 2014
Added support ATmega256RFR2 based Pinoccio Scout platform with examples
Version 1.41 April 2014
Fixed interframe delay for JVC protocol
Version 1.4 – March 2014
Added IRLIB_ prefix to debug macros to avoid name collisions
Debug macros now report more information
/* IRLib.cpp from IRLib - an Arduino library for infrared encoding and decoding
* Version 1.4 March 2014
* Version 1.41 April 2014
* Copyright 2014 by Chris Young
* This library is a major rewrite of IRemote by Ken Shirriff which was covered by
......@@ -141,7 +141,7 @@ void IRsendPanasonic_Old::send(unsigned long data)
void IRsendJVC::send(unsigned long data, bool First)
sendGeneric(data, 16,525*16*First, 525*8*First, 525, 525,525*3, 525, 38, true);
if(First) sendGeneric(data, 16,0,0, 525, 525,525*3, 525, 38, true);
/* IRLibTimer.h from IRLib an Arduino library for infrared encoding and decoding
* Version 1.4 March 2014
* Version 1.42 May 2014
* Copyright 2014 by Chris Young
* This library is a major rewrite of IRemote by Ken Shirriff which was covered by
......@@ -80,7 +80,11 @@
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
//#define IR_USE_TIMER1 // tx = pin 13
#define IR_USE_TIMER2 // tx = pin 14
// Pinoccio Scout
#elif defined(__AVR_ATmega256RFR2__)
#define IR_USE_TIMER3 // tx = pin D3
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc
//#define IR_USE_TIMER1 // tx = pin 9
......@@ -192,6 +196,8 @@
#define TIMER_PWM_PIN 5 /* Arduino Mega */
#elif defined(__AVR_ATmega32U4__)
#define TIMER_PWM_PIN 5 /* Arduino Leonardo note already checked for Teensy */
#elif defined(__AVR_ATmega256RFR2__)
#define TIMER_PWM_PIN 3 /* Pinoccio Scout */
#error "Please add OC3A pin number here\n"
IRLib – an Arduino library for infrared encoding and decoding
Version 1.32 January 2014
Version 1.42 May 2014
Copyright 2013, 2014 by Chris Young
This library is a major rewrite of IRemote by Ken Shirriff which was covered
......@@ -70,6 +70,8 @@ Samsung36 Demonstrates how to expand the library without recompiling it.
DirecTV Demonstrates additional protocol for DirecTV
GIcable Demonstrates additional protocol for GIcable used by Motorola cable boxes
rcmm Additional protocol Phillips RCMM used by AT&T U-Verse boxes
pinoccio Demo sketches for Pinoccio Scout platform using ATmega256RFR2
Arduino compatible platform. See readme.txt in pinoccio folder for details.
Note: I did not port any of the other demo sketches although I may add IRTest later.
The manuals directory contains:
IRLibReference.docx Reference manual in Microsoft Word format
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.42 May 2014
* Copyright 2014 by Chris Young
* Based on original example sketch for IRremote library
* Version 0.11 September, 2009
* Copyright 2009 Ken Shirriff
* IRLib: IRrecvDumpScout - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* This is a version of IRrecvDump modified for use with Pinoccio Scout
* Based upon "Bootstrap.ino" by the Pinoccio team
#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
#include <Arduino.h>
#include <IRLib.h> //Include the library
int RECV_PIN = 4; //Any digital I/O pin would work. We recommend 4
IRrecv My_Receiver(RECV_PIN);
IRdecode My_Decoder;
unsigned int Buffer[RAWBUF];
void setup()
My_Receiver.enableIRIn(); // Start the receiver
void loop() {
if (My_Receiver.GetResults(&My_Decoder)) {
//Restart the receiver so it can be capturing another code
//while we are working on decoding this one.
/* IRsendScout: adds "ir.send(p,c,b)" scout script command
* Version 1.42 May 2014
* Copyright 2014 by Chris Young
* Based upon "Bootstrap.ino" by the Pinoccio team
* Parameters are from protocol number 0-7, Up to 32 bit data,
* and number of bits for the protocols that required.
* You must use 3 parameters therefore number of bits
* should be 0 if not needed.
#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
#include <IRLib.h> //Add IRLib library
IRsend My_Sender; //Create a sending object
numvar irSend (void) {
unsigned char protocol = getarg(1);
unsigned long code = getarg(2);
unsigned char bits = getarg(3);
RgbLed.setColor(255,0,0); //just to confirm it works, turn on red LED
My_Sender.send((IRTYPES)protocol,code,bits); //Send it
RgbLed.turnOff(); //turn it off
void setup() {
addBitlashFunction("ir.send", (bitlash_function)irSend);
// Add custom setup code here
void loop() {
// Add custom loop code here
IRLib – an Arduino library for infrared encoding and decoding
Version 1.42 May 2014
Copyright 2013, 2014 by Chris Young
This library is covered by the GNU LESSER GENERAL PUBLIC LICENSE.
This readme is for the Pinoccio section only.
The Pinoccio Scout is a crowd sourced funded project from Indiegogo. It is in Arduino-like platform
based on the Atmel ATmega256RFR2 8-bit processor with 256K flash memory, 30 2K SRAM,
8K EEPROM and a built-in 2.4 GHz 802.15.4 mesh radio, LiPo battery, RGB LED, temperature sensor, and
an available Wi-Fi backpack. Is billed as "A Complete Ecosystem for Building the Internet of Things".
(By the way Pinoccio is not a typo. They really do spell it without the "h")
It is currently only available to the original backers but will be available shortly as a public beta test.
For more information on the platform see
This IRLib package automatically detects the ATmega256RFR2 processor in IRLibTimer.h. We have included
a Pinoccio Scout specific version of the IRrecvDump sample sketch for receiving IR signals. There is also
sketch that adds an "ir.send(p,c,b)" command to the Scout Script language used by the system.
You can use the portal on a Google Chrome browser to send IR codes using this command.
You should be able to adapt any other sample sketches or IRLib code of your own into the Pinoccio
infrastructure files by looking at those examples we provide.
We have also included a simple web-based application using the "ir.send" function. The IR codes in this
app are set up for my Samsung TV and my Cisco/SA cable box. You can edit remote .js to enter
your own codes. This web app is in simple HTML and JavaScript. It will run on a Windows-based PC
on Internet Explorer just as a static file off of your hard drive without any web server at all. If you have
a node JS web server on local host it will also run using Google Chrome and Mozilla Firefox. You can
also hosts it on a public web server but your authentication token needs to be hardcoded in or you will
have to write your own login front end.
The only available timer on this platform is TIMER 3. Output IR LED circuit should be connected to
digital pin D3. Any input pin can be used for receiving but we recommend D4.
The folder contains:
IRrecvDumpScout Pinoccio Scout version of IRrecvDump sample sketch decoding codes.
IRsendScout Sketch adds "ir.send(p,c,b)" command to Scout Script
html Folder contains a simple web application in HTML and JavaScript for a
TV and cable box remote control use with IRsend Scout.
<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="remote.css" />
<script src=""></script>
<script src= "remote.js"></script>
<h1>Pinoccio IR Remote</h1>
Edit the "remote.js" to include your token, troop ID, and scout ID.<br>
Connect an IR LED to pin D3 using a driver circuit.<br>
Click <a href="iriopinoccio1.png">here for a schematic of simple circuit</a> which has limited range.<br>
Click <a href="iriopinoccio.png">here for a more advanced circuit</a>.<br>
Note that you do not need the receiver portion for this page to work.<br>
<div id="LoginResults">
<table><tr height=80><td>
<div id="KeyMessage"> &nbsp;</div>
<div id="RemoteErr">&nbsp;</div>
<table id="RemoteTable">
<script>myInitialize(); </script>
.error{ color:#ff0000; }
body {font-family:Arial, Helvetica, sans-serif;}
h1 {text-align: center;}
.MyButtons {background-image: url("button.png"); width:59px; height:59px;
text-align: center; vertical-align: middle; font-weight: bold}
#KeyMessage {white-space:pre;}
.Big {font-size:20pt}
var api=pinoccioAPI();
//Enter your token here. Also troop ID and scout ID
api.token="enter your token here";
var troopid= 1;//replace this "1" with your troop ID
var scoutid=1;//replace this "1" with your scout ID
//handles to various parts of the screen. Initialized in myInitialize()
var LoginResults, RemoteErr, RemoteTable, KeyMessage;
var SendingFlag, DisplaySymbols;
var myAccount= {};
var HotKeys= [];
// The codes below are for a Samsung TV and a Cisco/SA Bright House cable box
// You can edit it for any codes you want. Also any number of rows and columns.
// Each entry is protocol number, code, number of bits, label, keycode
var Button= [//object containing all buttons
[//object containing row 0
[7,0xe0e0e01f,0, "V+",187],//Object containing button 1
[5,0x37c906,0, "|&#9668;&#9668;",74],//jump back "J"
[5,0x37291a,0, "&#9668;&#9668;",36],//rewind
[5,0x37990c,0, "&#9658;",32],//play
[5,0x36293a,0, "&#9658;&#9658;",35],//fast-forward
[5,0x36113d,0, "1",49],
[5,0x37111d,0, "2",50],
[5,0x36912d,0, "3",51]
[//row 1
[7,0xe0e0d02f,0, "V-",189],
[5,0x36b129,0, "&#9658;&#9658;|",78],//live "N"
[5,0x375914,0, "<span class='error Big'>&#9679;</span>",82],//record "R"
[5,0x374117,0, "||",80],
[5,0x365934,0, "<span class='Big'>&#9632;</span>",83],//Stop
[5,0x37910d,0, "4",52],
[5,0x365135,0, "5",53],
[5,0x375115,0, "6",54]
[//row 2
[7,0xe0e0f00f,0, "Mute",81],
[5,0x36c127,0, "Guide",71],
[5,0x37d904,0, "PgDn", 34],
[5,0x36812f,0, "<span class=' Big'>&#8657;</span>",38],//up arrow
[5,0x36d924,0, "PgUp",33],
[5,0x36d125,0, "7",55],
[5,0x37d105,0, "8",56],
[5,0x363139,0, "9",57]
[//row 3
[5,0x377111,0, "Ch+",85],
[5,0x366932,0, "Exit",88],
[5,0x37810f,0, "<span class=' Big'>&#8656;</span>", 37],//left arrow
[5,0x366133,0, "OK",13],
[5,0x364137,0, "<span class=' Big'>&#8658;</span>",39],//right arrow
[5,0x36213b,0, "Info",73],
[5,0x373119,0, "0",48],
[5,0x36b928,0, "Zoom",90]
[//row 4
[5,0x36f121,0, "Ch-",68],
[5,0x36e123,0, "Prev",86],
[5,0x373918,0, "Menu",77],
[5,0x37a10b,0, "<span class=' Big'>&#8659;</span>",40],//down arrow
[5,0x36c926,0, "List",76],
[5,0x37e902,0, "A",65],
[5,0x36193c,0, "B",66],
[5,0x37191c,0, "C",67]
[//row 5
[5,0x37b908,0, "PIP",84],
[5,0x377910,0, "PIP<br>Move",220],
[5,0x367930,0, "PIP<br>Swap",191],
[5,0x37f900,0, "PIP-",188],
[5,0x36e922,0, "PIP+",190],
[5,0x37f101,0, "Fav",70],
[5,0x37c107,0, "Cbl<br>Pwr",0],
[7,0x0e0e0f0bf,0, "TV<br>Pwr",0]
[//row 6
[5,0x0e163d,0, "Day-",219],
[5,0x0fe603,0, "Day+",221]
[0,0x0,0, "",0],
[0,0x0,0, "",0],
[0,0x0,0, "",0],
[0,0x0,0, "",0],
[0,0x0,0, "",0]
function copy_properties (d,s) {for(x in s)d[x]=s[x];}
function myDisplayErr(handle,s,err) {
handle.innerHTML= "<span class='error'>Error during "+s+err.code
+" '"+err.message+"'</span>";
function myGetAccountInfo(verbose,cb){{url:"/v1/account"},
function(err,data) {
if(err) {
if (verbose)myDisplayErr(LoginResults,"getting account info ",err);
} else {;
function myInitialize() {
RemoteErr=document.getElementById ("RemoteErr");
document.onkeydown= function(e){KeyHandler(e);};
function(err) {
if(err) {
RemoteErr.innerHTML="Error with Token ='"+api.token+"' troop ID: "+troopid+
" scout ID: "+ scoutid;
} else {
"Welcome "+myAccount.firstname+" "+myAccount.lastname+
"&nbsp; &nbsp; &nbsp; You are logged in '";
SetupHotKeys ();
DisplaySymbols= false;
ShowRemote ();
function KeyHandler (e) {
var x,r,c,s;
e = e || window.event;
if(e.which) x=e.which; else x=e.keyCode;
if(x==27) {DisplaySymbols=!DisplaySymbols;ShowRemote(); return;}
s = TranslateSpecial(x);
var t="You pressed '"+s+"' ("+x+")";
SendButton(t+" which corresponds to",HotKeys[x][0],HotKeys[x][1]);
RemoteErr.innerHTML= "";
function IRsend(protocol, code, bits) {
if(protocol==0) return;
if(SendingFlag) {RemoteErr.innerText= "Ignoring Command while waiting on return."; return;}
RemoteErr.innerText= "Attempting sending..."; (
function (err,data) {
var txt= "";
if(err) {
txt =err.code+ " message: "+err.message;
} else {
txt = "Sent:"+ protocol+ ", 0x"+code.toString(16)+ ", "+ bits;
function TranslateSpecial(x) {
switch(x) {
case 187:s="+"; break; case 189:s="-"; break;
case 36:s="HOME"; break; case 35:s="END"; break;
case 38:s="UPAR"; break; case 40:s="DNAR"; break;
case 37:s="LFAR"; break; case 39:s="RTAR"; break;
case 33:s="PGUP"; break; case 34:s="PGDN"; break;
case 13:s="ENTER"; break; case 32:s="SPACE"; break;
case 219:s="["; break; case 221:s="]"; break;
case 188:s=","; break; case 190:s="."; break;
case 191:s="/"; break; case 120:s="|"; break;
case 20:s="ESC"; break;case 220:s="\\"; break;
case 0:s="-na-"; break;
default:s= String.fromCharCode(x);
return s;
function SetupHotKeys () {
for(var k=0;k<256;k++) HotKeys[k]=[-1,-1];
function ShowRemote () {
var r,c;
RemoteTable.innerHTML= "";
for(r=0;r< Button.length;r++) {
var TR= document.createElement ("tr");
var TD= "";
for(var c=0;c<Button[r].length;c++) {
TD=TD+"<td class='MyButtons' onclick='DoButton("+r+","+c+")'>"+
if(Button[r][c][4]>0) HotKeys[Button[r][c][4]]=[r,c];
TR.innerHTML =TD;
function DoButton (r,c) {
SendButton("You clicked",r,c);
function SendButton (t,r,c) {
var B= Button[r][c];
KeyMessage.innerHTML=t+" button("+r+","+c+")='"+B[3]+
"' Protocol:"+ B[0]+" Code:0x"+B[1].toString(16)+
" Bits:"+B[2];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment