Zoomer Dino Controlled by Arduino IR Remote

satb100

One of the hottest toys this Christmas is the Zoomer Dino. It is a remote-controlled self balancing two wheel robot dinosaur with an infrared remote. I got one for my 10-year-old nephew for Christmas and after playing around with it I had to get one of my own. I have been thinking about building Arduino powered two wheel balancing robot from scratch but here was one that works right out of the box. I’m not sure if it has a gyro or accelerometer to keep it balanced. He rolls around on his own making noises including burps, farts, and laughs. You can also take over control with an infrared remote. The remote has a joystick and three pushbuttons. The joystick moves the head up, down, left, right. If you hold in the “run” button while moving the joystick he rolls around under your control rather than moving the head. There also is a button for “chomp” which makes his jaw chomp open and closed. Additionally there is a “angry” button which makes his eyes glow red and he thrashes around angrily.

Zoomer Dino and IR remote

Zoomer Dino and IR remote

As with my IR controlled to a helicopter before, I had to see if I could reverse engineer the protocol it was using for the remote control. It was one of the most challenging IR reverse engineering projects I’ve ever encountered. I finally had to go out and purchase one for myself because I had to wrap up the original one for my nephew.

I used my IRLib Arduino Library for decoding and encoding IR signals. Once you push a button to get things started, the remote puts out a continuous signal that is the neutral position of the joystick with no buttons pushed. I came up with a raw dump of the timing values using my IRrecvDump sample sketch. Here are the results.

Decoded Unknown(0): Value:0 (0 bits)
Raw samples(54): Gap:43480
  Head: m9250  s4750
0:m550 s650	1:m500 s650		 2:m550 s650	3:m550 s1800		 
4:m500 s650	5:m550 s650		 6:m550 s650	7:m550 s650		 
8:m550 s1750	9:m550 s650		 10:m550 s650	11:m550 s650		 
12:m550 s650	13:m500 s700		 14:m500 s650	15:m550 s650		 

16:m550 s1800	17:m500 s1800		 18:m550 s650	19:m550 s1750		 
20:m550 s1750	21:m550 s1800		 22:m500 s1800	23:m550 s650		 
24:m550 s650	25:m500
Extent=53300
Mark  min:500	 max:550
Space min:650	 max:1800

This is a quite typical set of signals used by many protocols. Only the timings and number of bits are unique. We have a header that consists of about 9200 mark and 4800 space followed by 25 data bits and a closing mark. The data marks run about 500 or 550. The data spaces are either about 650 or 1800. This variable spacing is the most common way to encode zeros and ones. We’ll call the short spaces ones and the long spaces as ones. I created a custom decoder object as follows.

#include 
#include 

class IRdecodeDINO: public virtual IRdecodeBase
{
public:
  bool decode(void); 
  void DumpResults(void);
};
#define DINO_HEAD_MARK   9200
#define DINO_HEAD_SPACE  4800
#define DINO_ZERO_MARK    500
#define DINO_ZERO_SPACE   650
#define DINO_ONE_MARK     500
#define DINO_ONE_SPACE   1800
#define DINO_SAMPLES 54
#define DINO_BITS 25

#define DINO (LAST_PROTOCOL+1)
void IRdecodeDINO::DumpResults(void) {
  Serial.print(F("Decoded DINO: Value:")); Serial.println(value, HEX);
};
bool IRdecodeDINO::decode(void) {
  IRLIB_ATTEMPT_MESSAGE(F("DINO"));
  if(!decodeGeneric(DINO_SAMPLES,DINO_HEAD_MARK, DINO_HEAD_SPACE,
    0, DINO_ZERO_MARK, DINO_ONE_SPACE, DINO_ZERO_SPACE)) return false;
  decode_type= static_cast<IRTYPES>DINO;
  return true;
};

IRdecodeDINO My_Decoder;

int RECV_PIN =11;

IRrecv My_Receiver(RECV_PIN);
long Previous;

void setup()
{
  Previous=0;
  Serial.begin(9600);while (! Serial);delay(1000);
  Serial.println(F("Send a code from your dino remote and we will decode it."));
  My_Receiver.enableIRIn(); // Start the receiver
}
void loop() {
    if (My_Receiver.GetResults(&My_Decoder)) {
    My_Decoder.decode();
    if(My_Decoder.decode_type == DINO) {
      if(My_Decoder.value!=Previous) My_Decoder.DumpResults();
      Previous= My_Decoder.value;
    }
    else Serial.println("Unknown");
    My_Receiver.resume(); 
  }
} 

Because the remote sends signals continuously, this routine only reports the initially received value and then anytime the value changes to something different. It outputs 6 hex digits but note that there are 25 data bits being received. I then plugged the hex values into an Excel spreadsheet, converted them to decimal, and then parsed out the individual bits to try to deduce a bit pattern. I tried leaving the joystick alone when pushing the 3 buttons individually. Then I tried moving the joystick full throw forward, backwards, left, and right. The results are shown in the table below. You may click the table image to enlarge it.

Table 1-Bit patterns from Dino remote.

Table 1-Bit patterns from Dino remote.

In all samples, the first three bits were always zero as was the last bit. It was pretty obvious that after the initial zero bits, there was a five bit field that was the left/right position of the joystick with the left position having a value of zero, the center as 16, and the right was 31. This was followed by another five bit field that was the forward/backwards joystick position with zero to the back, 16 in the center and 31 full forward. The next three bits were obviously the three buttons. There were eight additional bits that seem to have no rhyme or reason to them.

Here is a revised version of the receiving code that parses out the bits into their individual fields.

#include
#include

class IRdecodeDINO: public virtual IRdecodeBase
{
public:
bool decode(void);
void ParseFields(void);
void DumpResults(void);
unsigned JoyX, JoyY, Parity;
char Chomp, Angry, Run;
};
#define DINO_HEAD_MARK 9200
#define DINO_HEAD_SPACE 4800
#define DINO_ZERO_MARK 500
#define DINO_ZERO_SPACE 650
#define DINO_ONE_MARK 500
#define DINO_ONE_SPACE 1800
#define DINO_SAMPLES 54
#define DINO_BITS 25

#define DINO (LAST_PROTOCOL+1)
void IRdecodeDINO::ParseFields(void) {
long Temp = value>>1;
Parity = Temp & 0x0ffL; Temp= Temp>>8;
Run = Temp & 0x1L; Temp= Temp>>1;
Angry = Temp & 0x1L; Temp= Temp>>1;
Chomp = Temp & 0x1L; Temp= Temp>>1;
JoyY = Temp & 0x1fL; Temp= Temp>>5;
JoyX = Temp & 0x1fL;
};
void IRdecodeDINO::DumpResults(void) {
ParseFields();
Serial.print(F("Decoded DINO: Value:")); Serial.print(value, HEX);
Serial.print ("\tJX:"); Serial.print(JoyX,DEC);
Serial.print ("\tJY:"); Serial.print(JoyY,DEC);
Serial.print ("\tCh:"); Serial.print(Chomp,BIN);
Serial.print (" Ag:"); Serial.print(Angry,BIN);
Serial.print (" Run:"); Serial.print(Run,BIN);
Serial.print (" Parity:"); Serial.println(Parity,HEX);
};
bool IRdecodeDINO::decode(void) {
IRLIB_ATTEMPT_MESSAGE(F("DINO"));
if(!decodeGeneric(DINO_SAMPLES,DINO_HEAD_MARK, DINO_HEAD_SPACE,
0, DINO_ZERO_MARK, DINO_ONE_SPACE, DINO_ZERO_SPACE)) return false;
decode_type= static_castDINO;
return true;
};

IRdecodeDINO My_Decoder;

int RECV_PIN =11;

IRrecv My_Receiver(RECV_PIN);
long Previous;

void setup()
{
Previous=0;
Serial.begin(9600);while (! Serial);delay(1000);
Serial.println(F("Send a code from your dino remote and we will decode it."));
My_Receiver.enableIRIn(); // Start the receiver
}
void loop() {
if (My_Receiver.GetResults(&My_Decoder)) {
My_Decoder.decode();
if(My_Decoder.decode_type == DINO) {
if(My_Decoder.value!=Previous) My_Decoder.DumpResults();
Previous= My_Decoder.value;
}
else Serial.println("Unknown");
My_Receiver.resume();
}
}

But what to do about those parity bits? I had to presume they were some sort of checksum or other data verification field. Normally when capturing and decoding IR signals I really don’t care what the data represents internally. I point a TV remote at my receiver circuit, capture the hex value, and then re-create that value using my IR transmitter. I could have just quit now and build an application on the Arduino that would transmit button pushes and fixed joystick positions but it would be nice to be able to use any joystick position that I wanted from 0- 31 in either X or Y directions in any combination. But to do that I needed to figure out how to compute those additional eight bits of data.

Most consumer-electronics protocols use a simple checksum of adding the previous data fields together. Sometimes you take the 1’s complement of the data and repeat it. Sometimes you use bitwise XOR to combine the fields. I spent three days playing around with various versions of my Excel spreadsheet analyzing lots of bit patterns captured from the remote and could not deduce the pattern. I asked a couple of online acquaintances if they had any suggestions but they’re only input was to try checksum, XOR etc. A cyclical redundancy check or CRC was another option but that would be hard to reverse engineer and they generally are not used for such short streams of data. Keep in mind were only talking about 13 bits of actual data if you don’t count the leading and trailing zeros or the eight check bits.

At one point I remembered there was something called a Hamming error correction code. I had learned about them in college in my CS 484 class with Dr. Judith Gersting over 25 years ago. I barely understood how they worked back then and I’ve not used them ever since so the chances of me being able to figure it out on my own were represented by the three initial zeros in the data stream 🙂 Dr. Judith Gersting was not my only mentor in college. Her husband Dr. John Gersting told us on the first day of programming class that he was not going to teach us programming. He was going to teach us to teach ourselves programming because the minute we walked out the door, everything would probably be obsolete anyway. He literally handed us a textbook that he wrote and told us to go teach ourselves the course. I guess I was going to have to do some Google searches and teach myself everything I needed to know about Hamming codes.

As it turns out there is no one single way to create an error detecting/correcting code. There are entire websites devoted to multitudinous ways and they all use notation that I didn’t understand. I did find one website from UMass linked here.

http://www.ecs.umass.edu/ece/koren/FaultTolerantSystems/simulator/Hamming/HammingCodes.html

One thing I have learned about Hamming codes was that they typically only add a vary few extra bits. Using the calculator linked above if I put in a 16-bit value it would only add five additional bits. I was getting eight additional bits on just 13 bits of data. But the one thing I did learn from that page was the way you calculate those extra parity bits. There is a matrix that tells you which of the data bits to add together to get each of the individual parity bits. I really had to do was figure out which data bits contributed to each parity bit. I had already noticed that if you push the “run button” which I have listed as “B0”, that parity bits P2,P1,P0 all inverted from their normal position. Similarly the “angry button” which is “B1” toggles parity bits P3,P2,P1. Similarly the “chomp button” labeled “B2” toggles P4,P3,P2.

So I made a new set of columns in the spreadsheet to compute the parity bits. I begin by saying…


P0=B0
P1=B0+B1
P2=B0+B1+B2
P3=B2+B1
P4=B2

Additionally the center position of the joystick had only a single bit set, the highest order bit of the five bit field which was value 16. By comparing those to the joystick positions which were all of the way left or on the way back (which consisted of all zeros) I could figure out which parity bits changed based solely on X4 and Y4. Quite by chance I also found had captured samples with X positions of exactly 8, 4, and 2. So that told me which parity bits were based upon X3, X2, X1, and X0. As I updated the formulas for calculating each parity bit, I compared the computed results to actual capture values for every hex value I’d captured. I had a list of over 30 values that I had dumped from simply wiggling the joystick around. Eventually I was able to fill in the blanks and came up with the following formulas.

P0=X4+X0+Y4+Y3+B0
P1=X4+X1+Y3+B1+B0
P2=X4+X2+X0+Y3+B2+B1+B0
P3=X3+X1+Y4+Y0+B2+B1
P4=X4+X0+Y1+Y0+B2
P5=X3+X1+Y2+Y1+Y0
P6=X4+X2+Y3+Y2+Y1
P7=X3+Y4+Y3+Y2

Comparing my computed results to all my captured results I was convinced I had completely deduced how the parity bits were calculated. When you put those results in a table as follows, there is a definite pattern to them. It looks a lot like the patterns that had been seeing on various websites.

Table 2-Parity calculation matrix.

Table 2-Parity calculation matrix.

Finally I was able to create a sending routine that allowed me to test all of this out. This is a somewhat stripped-down version of what I ultimately came up with. You upload the sketch, call up the serial monitor, and type various characters into the monitor. The sketch then interprets those as commands and sends the proper hex code to the IR transmitter.

#include
#include

class IRsendDINO: public virtual IRsendBase
{
public:
void send(unsigned long data);
};
#define DINO_HEAD_MARK 9200
#define DINO_HEAD_SPACE 4800
#define DINO_ZERO_MARK 500
#define DINO_ZERO_SPACE 650
#define DINO_ONE_MARK 500
#define DINO_ONE_SPACE 1800
#define DINO_SAMPLES 54
#define DINO_BITS 25

#define DINO (LAST_PROTOCOL+1)

void IRsendDINO::send(unsigned long data) {
sendGeneric(data,DINO_BITS,DINO_HEAD_MARK, DINO_HEAD_SPACE,
DINO_ONE_MARK, DINO_ZERO_MARK,DINO_ONE_SPACE, DINO_ZERO_SPACE, 38, true, 0);
delay(27);//Average gap was 26700 us
};

IRsendDINO My_Sender;

int RECV_PIN =11;

IRrecv My_Receiver(RECV_PIN);
char Mult, Normal, Chars;
#define COUNT 7

void SendMultiple(unsigned long Data, char Count) {
for(char i=0;i<(Count);i++) {My_Sender.send(Data);}; }; void setup() { Serial.begin(9600);;delay(2000);while (! Serial);delay(2000); Serial.println(F("Enter one of the following letters A,C,U,D,L,R,F,B,<,>,N,0"));
Normal=1;
};
void loop() {
char Cmd;
if (Serial.available()>0) {
switch (Cmd) {
case 'A': SendMultiple(0x2105a0, 9); break; //anger
case 'C': SendMultiple(0x201984, 6); break; //chomp
case 'U': SendMultiple(0x21f162, COUNT); break; //head up
case 'D': SendMultiple(0x2000ae, COUNT); break; //head down
case 'L': SendMultiple(0x010112, COUNT); break; //head left
case 'R': SendMultiple(0x3f003a, COUNT); break; //head right
case 'F': SendMultiple(0x21f36c, COUNT); break; //forward
case 'B': SendMultiple(0x2002a0, COUNT); break; //backwards
case '<': SendMultiple(0x01031c, 5); break; //spin left case '>': SendMultiple(0x3f0234, 5); break; //spin right
case 'N': Normal=1; break; //send neutral commands
case '0': Normal=0; break;//send wiggle commands
}
} else {//if no serial data then send either normal play mode or sit still
if(Normal) {
//Un-comment next line to have Dino do normal behavior.
// My_Sender.send(0x2101bc); //Comment out to turn off continuous transmission
} else { //wiggle slightly in an attempt to set still
My_Sender.send(0x21132c);
My_Sender.send(0x20f27e);
}
}
}

The actual remote sends continuous streams of data even when you aren’t doing anything. If you don’t touch any buttons or move the joystick for about one minute it eventually shuts down. If you are not pushing a button and the joystick is in the neutral position, the dinosaur engages in various preprogrammed behaviors. I needed a way to get him to sit still while I’m typing in the next string of letters. If you select “Normal” mode. It doesn’t send any signals. If you press a “0” it continuously sends a tiny forward and backwards code which basically has him sit in one place. He wiggles a tiny bit and make some noises but he doesn’t go off on his own. Then when you type other letters he goes in the direction you want him to. You can look at the “switch statement” to see which characters perform which functions. I send multiple transmissions of each code. The default number of signals is defined in COUNT so it was easy to change the default. I have a more advanced version of the sketch which causes him to move at various speeds, shake his head repeatedly, travel in zigzag motions etc. I also added commands to make him go forward and right or forward and left simultaneously. That way he doesn’t spin in place, he turns in a broad curve. In the demo video below I use that feature to make him travel in an oval-shaped pattern.

Know that all of the driving patterns I put him through in the video below could be done with the actual remote. You’ll have to trust me that they were created using an Arduino and my software.

My ultimate goal is to port my code to my pinoccio board which includes Wi-Fi and mesh radio. That way I can control him through a webpage similar to this. I will end up with an “Internet of things” remote control dinosaur. The pinoccio has a LiPo battery and is very small. I might just velcro it with an IR LED to the back of the dinosaur and not worry about maintaining a line of sight from my transmitter. I will post more details when and if I ever get that working.

Here is where I demonstrated the project on the Adafruit weekly Show-and-Tell on Google Plus Hangouts.

IRLib Updated to Version 1.5

We are pleased to announce that IRLib has been updated to version 1.5. IRLib is a library for Arduino-based microcontrollers that allows for the receiving, decoding, and sending of infrared signals. These new changes are a step forward in making the library less hardware platform dependent so that it can be more easily used by a variety of microcontrollers. These changes include…

  • New bit-bang option for PWM output frequency setting. Now can use any output pin with no hardware timers. Note:bit-bang output not as accurate as timer-based frequency selection.
  • Major rewrite of IRLibTimer.h to facilitate bit-bang. Separated hardware timer selection and specification into sending and receiving sections in order to implement bit-bang.
  • New IRfrequency class for detecting input frequencies. Previously was a stand-alone special sketch but now is a class including a DumpResults method.
  • New IRfreq and IRrecvDumpFreq illustrate simultaneous detection of frequency and pattern with both an IR learner and IR receiver is connected.
  • New #define USE_IRRECV define can be commented out to completely remove the interrupt driven IRrecv receiver class from the library. This resolves ISR conflicts with other libraries such as Tone() when not using IRrecv class.
  • New #define USE_DUMP define can be commented out to disable DumpResults methods. Saves code space when these methods are not needed.
  • Revised user manuals to document new features and correct previous documentation problems.

Note: The included user manual update is not yet available on the website at http://tech.cyborg5.com/irlib/docs/ but it will be updated shortly. New user manual is available with the library itself as a Microsoft Word .docx file as well as PDF and EPUB versions.
This library is available on GitHub at . For more information on this library see http://tech.cyborg5.com/irlib/

Resolving SSL Certificate Problems

I’ve been working with the new Pinoccio microcontroller Arduino-like platform for creating internet-of-things devices. One of the many ways you can access devices through a webpage called their headquarters. It is available at hq.pinocc.io and requires a special plug-in for Google Chrome. I had been having great success with the device and suddenly two days ago the webpage quick loading. At first I thought their server was down but eventually realized that I could login using other in my home but not the one that I had been using. It was the classic “why is this thing not like the others?” problem.

The folks at pinocc.Io were tied up in a maker fair and working on other issues and were not able to help me right away. So I did some exploring on my own.

I finally figured out that it was a problem with SSL certificates on a piece of JavaScript. I only figured that out by typing in the URL the JavaScript itself instead of the URL of the webpage. That gave me the following…
hq_problem2
Note you can click on any of these images for larger versions.

I clicked on the “MORE” and got the following information.
hq_problem3

That told me that the certificate had been revoked and it told me who had issued the certificate but that still tell me very much. The first problem was figuring out where in Google Chrome SSL certificates were handled. Several Google searches later I determined that chrome uses Windows computers default settings. You can get to it in Google Chrome’s settings under the section “proxy settings”. (Gee no wonder it didn’t jump right out at me!) You can also access SSL certificate information from Internet Explorer under Tools… Internet options… content tab. I tried clicking on the “clear SSL state” hoping that it would flush everything out and recheck the certificates. That didn’t help. I clicked on the “Certificates” button but couldn’t find anything related to the certificate issuer “Gandhi Standard SSL, CA” that I had gotten from that more detailed error message.

I browsed around the certificate section in Internet Options but could not find anything under any of the tabs regarding that provider. Then I noticed that where you type the URL there is a little green padlock icon that somehow was beckoning me to do a right-click on it.
SSL 4

When I did I got the following…
SSL2
The initial tab talks about permissions but I clicked on the Connection tab. Then I clicked on the Certificate Information link. Which gave me this…
SSL3
The details tab was interesting but didn’t really tell me much so I tried the “Certification Path” tab and got the following
SSL1
This gave me some other places to look. I started the top with USERTrust and found it under “Trusted Route Certification Authorities” here…
SSL 5
However it would not allow me to remove it. However under “Intermediate Certification Authorities” I found an entry that it would allow me to remove.
SSL 6
After clicking on the “Remove” button and closing everything out, I was able to go back into Google Chrome, access the website, and it loaded perfectly. It apparently went and got a fresh copy of the certificate. Now everything is working fine.

The folks at Pinocc.io later explained “We recently added a load balancer which was still configured with the pre
heartbleed ssl cert we revoked. This has been fixed.”

So if anyone is out there reading this whether they are using Pinocc.io or not and you are having SSL Certification problems perhaps the steps I’ve shown you will help.

Pinoccio Internet of Things IR Remote Demo

satb100Here is a YouTube video demonstrating how I created an internet of infrared remote using the new Pinoccio platform. The Pinoccio is an Arduino compatible board based on the ATmega256RFR2 chip. It uses a Wi-Fi backpacked and built-in 802.15.4 mesh radio.

As mentioned in the video I have not yet released my source code for the Pinoccio port of my IRLib but I will do so very soon. The source code is now available on GitHub here. Read more about Pinoccio (and yes it really is spelled without an “h”) at https://pinocc.io. And my IRLib at http://tech.cyborg5.com/irlib/

Update: I also did a live demonstration of this project on the Adafruit Industries Google+ Hangout weekly Show-and-Tell which you can see here…

At some point I will post an extensive tutorial on this project.

Pinoccio Wireless Arduino Compatible Board: First Impressions

My Pinocchio boards arrived today in the mail. By the way I’m going to continue to call them Pinocchio rather than it to spelling Pinoccio simply because it’s easier to dictate using my voice control software wherein I do not need to go back and delete the “h” each time I type the word. For an explanation of the name you can see their FAQ here.

This board started out as a crowdsource funded project on indiegogo.com. It was billed as “A Complete Eco-System for Building the Internet of Things”. It consists of an ATmega256RFr2 microprocessor, a USB interface, a temperature sensor, an RGB LED, and a LiPo battery. The mesh radio built into the chip is a 2.4 GHz transceiver supposedly capable of ZigBee and IEEE 802.15.4 transmission although I’ve not yet seen anything about how to communicate with X-Bee or ZigBee modules from other manufacturers.

The package I ordered as part of my funding sent me two modules, one of them with a Wi-Fi shield or backpack as they call them. They call the boards “Scouts” so the one with the Wi-Fi shield is the “Lead Scout” and those without Wi-Fi are called “Field Scouts”. As a milestone perk I also got a prototyping shield and a small USB cable for charging and configuring. Here are some photos of the devices as shipped. (Click the images for larger view.)

Everything I Got

Everything I Got


Topside view: Lead Scout with Wi-Fi on top. Field Scout below.

Topside view: Lead Scout with Wi-Fi on top. Field Scout below.


Bottom view showing battery.

Bottom view showing battery.


The units use a micro USB cable. The first one I tried was a mini USB with an adapter on it. The adapter was too large because it got in the way of the Wi-Fi shield. I finally found a cable in my pile of cables. I wanted to be able to plug in both of them at once but as it turns out that may be a bad idea.

There was a card included that says to get started I should open a chrome browser and go to hq.pinocc.io and download their chrome app. I thought about browsing around the website and reading a bunch of documentation but one of the things the designers have said is that it ought to be easy to get started. They spent a lot of time working on the software and the front end for this thing rather than just creating the hardware and sending them out. In fact the original deadline for shipping was last July and here is the following April. So I thought I would give it the acid test and play dumb and see what I can find.

The app loaded just fine and I got a screen that told me to click to add a Scout control panel. They call the control panel “HQ” The first thing it said I had to do was to downloading Windows driver and install it. They tell you to plug in the device first and then it would tell me that no driver was available. Then it suggested I go to Device Manager via Control Panel in Windows and then I would find the device under “Ports (COM & LPT)”. It was not there it was under “Other devices” which is no big deal. I downloaded the driver and unzipped it into a folder. I would’ve preferred a self extracting installer but that was no big deal. When I tried to install the driver, Windows for bid me because it was not signed. No mention of that fact in any of their documentation so minus a few points for that problem as well. This was a Windows 8.1 64 bit machine. I had had trouble loading Arduino drivers on my laptop for the same reason and I found a website that explains how to permanently turn off that feature. I don’t know why I had not had the similar problem with Arduino drivers on my desktop Windows 8.1 PC. If you are interested… here is the website that tells you how to do it. That went relatively well.

Then I went to the process of configuring the lead scout. It took me several attempts and some email exchanges with their technical support people. Eventually it did start working but I’m not really sure what we did to fix it. It seemed to me that the steps they outline history followed in an exact precise manner.

Scouts in a mesh are configured together in something called a “troop”. So the first thing you have to do is give it a troop name. I chose “The Collective” (as an homage to Star Trek’s Borg). Then you name your lead Scout. I chose “Picard”. It then searches for Wi-Fi signals and asks you which Wi-Fi it should try to connect to. You are the Wi-Fi from the list and enter your password. There’s also a manual option if it cannot detect your Wi-Fi. When you completed that a screen pops up telling you that it succeeded adding your lead Scout to the Scout HQ. It then tells you to unplug the device so that it will reset and reconnect to your Wi-Fi. After that you click on the button that says “Done”. Apparently they are very picky about the order. You cannot click done until you’ve unplug the device and give it time to reset. Even then I had difficulty getting it to work right. In the end the only reliable way I could configure it was to unplug it and turn its power switch off and on. Then wait a few seconds before clicking done. Oh by the way when you first plug it in, the HQ searches for it and tells you that he could not find the device and that you probably forgot to turn it on. But it doesn’t tell you where the switch is. It’s not obvious. Anyway after unplugging, cycling the power switch, waiting a few seconds, and then clicking the done button it seemed to work okay.

You go to the same process for the field Scout although it does not prompt you for Wi-Fi information since it doesn’t have Wi-Fi.

The HQ app gives you the ability to turn on the RGB LED and change colors. It tells you the percent your battery is charged any gives you the temperature from the temperature sensor. I took my field Scout outside to see what the outside temperature was. Unfortunately it was raining so we had to put it in a plastic bag when sitting it out on the back porch. I don’t know how accurate the temperature was but it did change to a reasonable value. There are also controls for configuring the several I/O pins. There’s also a command line for sending for sending script commands. Here are some screen grabs showing the two scouts.

HQ control panel for the lead scout "Picard"

HQ control panel for the lead scout “Picard”


HQ control panel for field scout "Seven-of-Nine"

HQ control panel for field scout “Seven-of-Nine”

There are variety of script commands that you can use on the command line. Here is a link to the reference page.

The next thing I tried to do was use the Arduino IDE. You have to download a beta version because the current IDE does not support that chip. Again is a zip file rather than an installer. I already had the current production Arduino IDE installed on this machine. I took a chance and just copied the new files over the old ones. Apparently that was not the right thing to do because when I tried to compile an example sketch I get a “compiler error” with no error message whatsoever. I will probably go back and uninstall original Arduino IDE and delete all the files and try to reinstall the beta version from scratch. But that’s a task for tomorrow.

It’s going to be a steep learning curve to do anything really useful with this. Of course my ultimate goal is to port my IRLib and use it to make an “Internet-of-Things” infrared remote. Let’s going to take lots of time with data sheets and schematics. It looks like as powerful system but are not a long way to go in order to get it to do what I wanted to do.

Revised Remote-Controlled Remote-Control with Call Button

Imagine yourself being a severely disabled person lying in bed at night and needing assistance. It might be that you’re uncomfortable and need to roll over. Sometimes it’s just something annoying like a bug crawling across your arm. Other times it’s more serious such as a severe coughing spell, nausea, or potentially even a heart attack. A couple of months ago I woke up in the middle of the night with chest pains. I was 99% sure it was just a muscle cramp. I had had my back brace on a little bit crooked that day and I was pretty sure it was just the aftermath of that. But I wasn’t really sure that it was not a heart attack. I tried calling my dad who sleeps in his bedroom which is pretty far from my room. As both of us have gotten older, my lungs are weaker and his hearing is worse. I can usually yell and wake him up in 10 or 15 minutes. However some nights he sleeps very soundly and it’s not unusual for me to lie in bed awake for an hour or even two until he gets into a lighter sleep cycle and can hear me.

As I was lying there in bed wondering if I needed to be calling 911 or if I just needed a rubdown with some BenGay, I wished that I had some sort of a call buzzer that would alert him that I needed something. Years ago I had a call buzzer that we built out of parts from RadioShack. It was part of their home security line of products. There was an emergency call button that you would wire into their control boxes and that control box could in turn be hooked into an auto dialer. We really didn’t need a button to call 911. We just wired in a loud buzzer. We had one for me and one for my grandmother. The radio on the button was strong enough that she could trigger hers in her home next door and it would buzz here.

In 1990 my grandmother passed away and I was using the buzzer myself less and less. We ended up putting it away somewhere because it wasn’t as critical for me and typically if dad didn’t hear me my mom did. In recent years I’ve looked for that gadget all over the house. I’ve looked through closets and junk boxes and junk drawers and cannot find it. RadioShack no longer makes the kind of gadget that we used. Their newer home security systems do not seem to have something similar. I guess they expect you to buy some commercial home security system that is monitored. You know the famous “I’ve fallen and I can’t get up” type of gadget.

So anyway I’m lying there thinking it would be really nice if I had a button in my hand that would trigger a buzzer to wake up my dad. But wait… I did have the button in my hand. I had four of them in fact. Unfortunately all they would do would be to turn on my TV. No buzzers attached.

In previous articles I’ve talked about my “Remote-Controlled Remote-Control” project that I use to control my TV, cable box and DVD players while in my bed.

Sitting in my wheelchair I have no problems pushing buttons on a remote. I use a wooden stick in my mouth.

Sitting in my wheelchair I have no problems pushing buttons on a remote. I use a wooden stick in my mouth.

When sitting up in my wheelchair, I poke at the buttons of a traditional universal remote by using wooden stick in my mouth. But when I’m in bed, I don’t have sufficient dexterity to handle a bunch of buttons.
Arduino-based device with LCD menu sits atop my TV probably displaying an Adafruit "As Seen on Show & Tell" sticker.

Arduino-based device with LCD menu sits atop my TV probably displaying an Adafruit “As Seen on Show & Tell” sticker.

Instead I have a system that uses a set of micro switches, universal remote, and the special electronic gadget that I built that sits on top of my TV. That gadget is based on an Arduino microcontroller. It has an LCD screen and an infrared receiver and transmitter. Below is a diagram of how down the original system worked. I have a set of four micro switches that I hold in my hand. They can be seen lying on the bed connected by wire to universal remote that is sitting on top my cable box. I would push the micro switch causing the universal remote to send an IR signal to the Arduino box on top of my TV. After selecting an item off of the menu the Arduino box would then send an IR signal back to the cable box. Note you can click on any of the images in this blog to see a larger version.
Original "Remote-Controlled Remote-Control" System

Original “Remote-Controlled Remote-Control” System

What I needed was an additional function to ring a buzzer. The problem is that infrared IR signals are just ordinary beams of light that happen to be of such a frequency below what the human eye can see. While it is possible to bounce the IR signals off of a shiny object or a light-colored wall, there’s no way that the signal was going to reach all the way to my dad’s room. That means we needed some sort of radio RF signal.
X-Bee Series 1 Radio

X-Bee Series 1 Radio


My microswitches were wired directly into a traditional universal remote. The box on top of my TV was designed by me and built by my dad and it was based on the Arduino series of microcontrollers. Lots of types of gadgets have been designed for use with these controllers. The most popular RF module is called an X-Bee radio.

I thought about adding an X-Bee to the Arduino on top of my TV, however to trigger it I would need to select that option from the LCD menu. However sometimes I sleep on my side and I could not see the menu. That meant that the X-Bee would have to somehow be connected to the microswitches directly. I concluded that I could build another Arduino gadget to replace the universal remote. The microswitches would wire into the new transmitter Arduino. It would send the IR signals to my set-top Arduino just like the remote did. But it would also have an X-Bee module that was sent RF signals to my dad’s room.

The X-Bee does have some digital input/output pins to which I could connect a buzzer directly. However I wasn’t really sure if it was going to be a buzzer perhaps something that would turn on a light or perhaps trigger an intercom. Since I wasn’t completely familiar with the capabilities of X-Bee and I do know a lot about Arduino I decided that the receiver in my dad’s room would also be an Arduino with an X-Bee connected to it.

Adafruit X-Bee Adapter

Adafruit X-Bee Adapter

I went to my favorite electronics supplier Adafruit.com and ordered the following gadgets (2 each) an Arduino micro, an X-Bee adapter that makes it easy to connect a 3 volt X-Bee to a 5 volt Arduino, an X-Bee Series 1 radio module, a USB cable, a 5 volt USB power supply. I already had parts to make an IR transmitter. The only other item I needed was some prototyping boards and a 5 volt buzzer.

I had no previous experience with X-Bee. It’s a pretty powerful system that allows you to create a network mesh of transmitters and receivers. You can configure them as a master controller which can control either end nodes or routers. The routers can talk to the master controller and to end points. I had several online tutorials and an e-book that many of them talked about the newer X-Bee series 2 devices and I was using the older and slightly less expensive series 1. It was a pretty steep learning curve until I finally found an article that explains how to set up the simplest possible X-Bee network. Here is the link…

http://jeffskinnerbox.wordpress.com/2013/03/20/the-simplest-xbee-network/

06 hayes_smartmodemThe author explains that X-Bee is really just an ordinary serial modem. In fact the firmware recognizes escape sequences and text commands that are based on an old system used by Hayes Smart Modems. I remember the days when I had an old Hayes Smart Modem 300 sitting on top of my S-100 bus-based computer back in the early 1980s. By the way that “300” wasn’t just a model number… It meant that it communicated at 300 baud. That is approximately 300 bits per second. Today’s Internet traffic is not measured in hundreds of bits per second rather in megabits per second. That shows you how old this system is. Typically an X-Bee radio communicate that 9600 baud.

FTDI USB cable and X-Bee Radio with Adapter

FTDI USB cable and X-Bee Radio with Adapter

Anyway you simply connect them to a USB port using an FTDI or an Arduino. Then you use a serial communication program to type text into the radio. Using the Hayes protocol you type “+++” with a pause before and after to get it into command mode. Then you type text commands beginning with the letters “AT” to configure various parameters. Once it is configured, anything that you type into one X-Bee gets transmitted and appears on the other radio. It’s like a little 2 man chat room.

There is a more advanced mode called API mode that allows you to send packets of digital data. But for my purposes all I needed to do was send one character of data that would be interpreted as “Ring the buzzer”.

I first prototyped everything on a breadboard to get it working. Then I had dad solder it all together neatly on a prototype board. Here is a photo of the receiver device that goes in my dad’s room. It consists of an Arduino Micro, an X-Bee radio sitting in the 5 V adapter board, and a buzzer.

Receiver module with buzzer

Receiver module with buzzer


Here is a photo of the transmitter device that sits on top of cable box. It shows the sets of 4 micro switches next to it. The small board on top is an IR transmitter consisting of three transistors and 2 IR LEDs.
Transmitter with IR emitters and microswitches

Transmitter with IR emitters and microswitches


Here is an illustration of how the system worked using the Arduino transmitter with X-Bee radio and IR transmitter in place of the universal remote.
Communication between Arduino devices

Communication between Arduino devices


I spent several days tinkering with the timing of the system. I had to deal with de-bouncing the micro switches. I also had to deal with conflicts between the IR signals going back and forth between the two boxes. The signal going from the transmitter to the box on top of the TV show by the green arrow would interfere with the signal going from the LCD menu box back to the cable box shown with the blue arrow. The Ghostbusters were right “Don’t cross the streams!”. The original universal remote had been configured to only send a signal once even if you held down the button. I wanted to be able to hold the button to send repeat signals so that it would be easier to scroll through the on-screen channel guide for example. But as the transmitter box with send a second signal, the LCD box would be trying to talk to the cable box and it would get confused.

One of the problems was that the transmitter was too intense. Those double LEDs each with their own driving transistor were putting out too much power. IR receivers have something called an automatic gain control or AGC. They automatically adjust to the amount of infrared light coming in. My ultrabright transmitter was bouncing off of the TV and other objects in the room and temporarily “blinding” the AGC on the IR receiver of the cable box. I ended up putting a piece of tape over one of the LEDs and that helped my timing issues a little bit. While I was able to get it working as well as the old system, I still couldn’t get the timing right to be able to hold the buttons for a continuous stream of pulses for scrolling through on-screen menus.

On the other hand the call buzzer worked pretty well. The first couple of nights that I tried it, my dad was able to hear the buzzer and come and roll me over or do whatever else I needed. I programmed the transmitter Arduino to only trigger the buzzer if I held down 2 buttons simultaneously for a duration of five seconds or more. That way I wouldn’t accidentally set off the buzzer while trying to change channels or do some other function on the TV. Also it meant that I did not need to add any additional buttons.

Completed buzzer with cone.

Completed buzzer with cone.

However a few nights later, dad was in a deeper sleep than he had been during the initial tests and did not hear the buzzer. I was going to go looking for a new buzzer that was perhaps louder. I had also considered adding a relay to the receiving Arduino that would perhaps turn on a lamp in his bedroom. But my dad had a better idea. He noticed that the sound coming from the buzzer was a bit directional. Since he is a retired sheet metal worker he naturally thinks of solutions that involve making things out of metal so that is what he did. He created a little metal cone that he fitted atop the buzzer using a little plumbing elbow. Here is a photo of the modified device and the little plastic box that he used for an enclosure. So far this modified device is working really well.
X-Bee mounted atop LCD menu box

X-Bee mounted atop LCD menu box

I still was not happy with my timing problems on the transmitter. I realized that I could avoid the IR interference if I added an X-Bee to the LCD box on top of my TV. Then we would have an RF signal going from my transmitter box to the LCD box and it would not interfere with the IR signal going from the LCD box to my cable box and DVD etc. I ordered another X-Bee and X-Bee adapter from Adafruit and it arrived in few days. We mounted it on top of the LCD box and wired it into the Arduino inside. Here’s what it looks like now.

We cut away the IR transmitter board from the transmitter Arduino and removed it. We then mounted the device in a plastic box. The boxes we were using were boxes that originally contained a deck of cards. It turns out they are just the right size for the Adafruit half-size prototyping board.

Completed transmitter with IR board removed

Completed transmitter with IR board removed


Completed transmitter painted black and sitting atop cable box

Completed transmitter painted black and sitting atop cable box

I eventually painted my box completely black because I didn’t like all the blinking LEDs lighting up my room at night. There is a green power LED and a red transmit LED on the X-Bee adapter and there is a bright blue power LED on the Arduino Micro.

Here is an illustration of how the new system works.

Communication between boxes in final version

Communication between boxes in final version

The X-Bee on the transmitter box sends RF signals to my dad’s bedroom and to the LCD box on top of the TV. That signal is shown by the magenta arrows. The LCD box then transmits IR signal back to the cable box shown in blue arrows. There is of course no interference between IR and RF so I don’t have to build in the special delays. I can pump the buttons as quickly as I want to or hold the button in and let the software pump the signal for me at whatever rate I want. It works wonderfully.

I mentioned earlier that X-Bee was capable of creating complicated networks with master controllers, routers, and in points. Was a bit worried I was going to have to learn how to do all that once I had added the third radio. As it turns out the simple system of everyone-talks-to-everyone works just as well with more than two radios. Therefore the same RF signal in the same data goes from the transmitter box to my dad’s receiver buzzer and to my LCD box. The data I am sending is just a single text character. If it sends a “^” character then the buzzer goes off. If it sends a “U”, “D”, “L”, “R”, or “S” character than it tells the menu box to move the cursor up, down, left, right, or select. Actually I do not have an up microswitch in the system. It’s easier to get by with just 4 buttons. The menu wraps around and sue if I need to go up, I just go down several steps.

satb100The whole thing is working really well. I demonstrated my original “remote-controlled remote-control” on the weekly Adafruit Show-and-Tell videoconference on Google+ Hangouts over a year ago when I first created it. Here is a link to that blog entry which contains the video demonstration. A few weeks ago I also demonstrated on the Show-and-Tell the initial X-Bee system that did not include the third radio. Below is the YouTube video of that Show-and-Tell.
Part of the segment begins about 8:30 into the video. I will probably do a follow-up demonstration of three radio system.

Here’s a list of the parts used with links to Adafruit.com

IRLib Now Supports U-Verse

IRLib Version 1.4 is now available on GitHub at https://github.com/cyborg5/IRLib/. It includes minor upgrades to the debugging macros, a new system for decoding based on absolute tolerance in microseconds rather than a percentage tolerance. Also included is a new example sketch which implements the Phillips RCMM Protocol. The 32-bit version of that protocol is used by AT&T U-Verse cable boxes. Note that there are some unusual timing requirements in this protocol. The decoding routine works best when used with the IRrecvLoop or IRrecvPCI receivers. The sending of IR codes however should work well.

Details about these changes in the unusual decoding requirements of this protocol will be included in an upcoming documentation on how to implement new protocols for this library. That documentation should be available in a few weeks.

Users Manual for IRLib Now Available

We are announcing the creation of a new users manual for IRLib. A library for Arduino for sending, receiving, and decoding infrared signals.

This is a work in progress. It will eventually contain three sections.

  1. Reference
  2. Tutorials and Examples
  3. Implementing New Protocols

Currently only the reference section has been completed. The tutorial section currently only links to previous blog posts that contain tutorials. That section will be expanded. The third section on new protocols will be written soon.

The documentation is available on the menu at the top of this page or at this link. http://tech.cyborg5.com/irlib/docs/

A Microsoft Word and Adobe PDF version of the document is also available in a new folder added to the GitHub repository for the code. That repository is available at.

https://github.com/cyborg5/IRLib/

Feel free to email me with corrections. There have to be a ton of typos in this thing 🙂

IRLib Updated to Version 1.3

A new version of IRLib is now available on GitHub at
https://github.com/cyborg5/IRLib/

Down three IRLib is a library of code for Arduino-based microcontrollers that facilitates sending, receiving, decoding and analyzing infrared remote signals. Here is an overview of the changes.

  • NEW FILES

    • Added new file IRLibRData.h and moved irparams structure and related items to that file. Allows users to create custom IRrecv classes
  • NEW EXAMPLES
    • Rewrote Samsung36 example to include both send and receive
    • Added new examples for new protocols DirecTV and GIcable
    • Added new example IRanalyze gives more detailed analysis of timing. Useful in analyzing the protocols
    • Added new example IRfreq reports modulation frequency of a signal. Requires TSMP58000 IR learner chip
    • Cleanup of other example routines.
  • NEW CLASSES
    • Created IRrecvBase class to allow custom receiver classes. IRrecv is now a derived class from it.
    • Created IRrecvLoop class which receives IR signals without using any hardware interrupts or timers. Also created IRrecvPCI class which uses Pin Change Interrupts to receive IR signals. These new receivers are more accurate than the 50µs timing of the original IRrecv. However they also have other limitations described in comments.
  • NEW FUNCTIONS, VARIABLES AND METHODS
    • In IRrecvBase added “unsigned char Mark_Excess” with default value 100. Was a define macro but now is user settable.
    • In IRrecvBase added method “unsigned char getPinNum(void);” which retrieves the pin number used from irparams.recvpin. This value not normally accessible to end user.
    • Globally available function “void do_Blink(void);” blinks pin 13 LED. For use by user created extensions of IRrecvBase.
  • INTERNAL CHANGES
    • Data collected by IRrecvBase classes in irparams.rawbuf is now converted to actual microseconds rather than clock ticks of 50 µs each. IRrecvBase::GetResults has a new parameter “Time_per_Ticks” that is used to convert ticks into actual microseconds if needed.
    • Adjustments to mark and space to deal with overreporting and underreporting of intervals is now done once in IRrecvBase::GetResults eliminating the need for MATCH_MARK(d,v) and MATCH_SPACE(d,v). Just use MATCH(d,v) everywhere.
    • Modified IRLibsendBase::mark() and IRLibsendBase::space() to overcome limitations of “delayMicroseconds()”.
    • Changed many int to char or unsigned char to save memory
    • Eliminated DEBUG macro in IRLib.h and its use elsewhere. Macro TRACE is more useful.
    • Changed IRTYPES to unsigned char and a list of #defines rather than an enum (even though I still really like enums, changing it saves memory)
  • MEMORY EFFICIENCY
    • Code changes result in memory savings of approximately 54 bytes in code space and 39 bytes of RAM.

    For more information see my IRLib page.

Programmable Christmas Lights Using Arduino and Neopixels

satb100I have a little Christmas tree that I put up in my office every year that I call my “Charlie Brown tree”. It’s a scrawny looking little artificial tree with a little white Christmas balls on it and a strand of cheap flights. This year I decided to fancy it up a little bit by adding a 3 meter strand of Adafruit neopixels containing 90 pixels. I started out with the standard strand test sketch that is available from Adafruit and then modified it to add my own special patterns. I showed it on a recent Adafruit Saturday night Show-and-Tell Google+ video chat. There were a number of other Christmas displays shown that night but people seem to especially like my candy stripe pattern.

One viewer liked it so much he wrote me and asked me for the candy stripe code. He then incorporated it into his outdoor display and showed it in a subsequent Show-and-Tell a few weeks later. I had always intended to write a blog post about it and to include the code but I got so busy over the holidays that I didn’t have time to clean up the code and make it suitable for public sharing. The holidays are over and I’m finally getting around to sharing the code.

Here is a YouTube video showing a slightly earlier version of the pattern.

Here is the Adafruit Show-and-Tell on Google+ where I showed off the tree and my blinking Christmas card.

Here is the Show-and-Tell of the other guy named Kenneth who borrowed my candy stripe code. His display used a full 10 meters of pixels. Unfortunately there were bad audio problems that evening but I will put the video here anyway. His segment starts at about six minutes into the video.

Here are some links to the products used in this project. All were purchased from Adafruit.com

Now finally here is the code edited for public consumption with comments.

#include <Adafruit_NeoPixel.h>

#define Count 12
#define Pin 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(Count,Pin,NEO_GRB + NEO_KHZ800);

#define Brightness 10 //Set brightness to 1/10th
#define Full (255/Brightness)
//Create scrolling red and white candy cane stripes.
//Try adjusting the width in pixels for various results.
//Value "sets" should evenly divide into strand length
void CandyCane  (int sets,int width,int wait) {
  int L;
  for(int j=0;j<(sets*width);j++) {
    for(int i=0;i< strip.numPixels();i++) {
      L=strip.numPixels()-i-1;
      if ( ((i+j) % (width*2) )<width)
        strip.setPixelColor(L,Full,0,0);
      else
        strip.setPixelColor(L,Full,Full, Full);
    };
    strip.show();
    delay(wait);
  };
};

//Create sets of random white or gray pixels
void RandomWhite (int sets, int wait) {
  int V,i,j;
  for (i=0;i<sets;i++) {
    for(j=0;j<strip.numPixels();j++) {
      V=random(Full);
      strip.setPixelColor(j,V,V,V);
    }
    strip.show();
    delay(wait);
  }
};
//Create sets of random colors
void RandomColor (int sets, int wait) {
  int i,j;
  for (i=0;i<sets;i++) {
    for(j=0;j<strip.numPixels();j++) {
      strip.setPixelColor(j,random(255)/Brightness,random(255)/Brightness,random(255)/Brightness);
    }
    strip.show();
    delay(wait);
  }
};
void RainbowStripe (int sets,int width,int wait) {
  int L;
  for(int j=0;j<(sets*width*6);j++) {
    for(int i=0;i< strip.numPixels();i++) {
      L=strip.numPixels()-i-1;
      switch ( ( (i+j)/width) % 6 ) {
        case 0: strip.setPixelColor(L,Full,0,0);break;//Red
        case 1: strip.setPixelColor(L,Full,Full,0);break;//Yellow
        case 2: strip.setPixelColor(L,0,Full,0);break;//Green
        case 3: strip.setPixelColor(L,0,Full,Full);break;//Cyan
        case 4: strip.setPixelColor(L,0,0,Full);break;//Blue
        case 5: strip.setPixelColor(L,Full,0,Full);break;//Magenta
//        default: strip.setPixelColor(L,0,0,0);//Use for debugging only
      }
    };
    strip.show();
    delay(wait);
  };
};
//These routines were modified from Adafruit strand test sketch
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

void rainbowCycle(uint8_t sets, uint8_t wait) {
  uint16_t i, j;
  for(j=0; j<256*sets; j++) { //cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(strip.numPixels()-i-1, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color((WheelPos * 3)/Brightness, (255 - WheelPos * 3)/Brightness, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color((255 - WheelPos * 3)/Brightness, 0, (WheelPos * 3)/Brightness);
  } else {
   WheelPos -= 170;
   return strip.Color(0,(WheelPos * 3)/Brightness, (255 - WheelPos * 3)/Brightness);
  }
}

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  randomSeed(1234);//Set up random number generator
}

void loop() {
  CandyCane(30,8,50);//30 sets, 8 pixels wide, 50us delay
  RainbowStripe(5,4,75);//5 cycles, 4 pixels wide, 50 delay
  RandomWhite(50,200);//50 sets of random grayscale
  RandomColor(50,200);//50 sets of random colors
  colorWipe(strip.Color(Full, 0, 0), 50); // Red
  colorWipe(strip.Color(Full, Full, 0), 50); // Yellow
  colorWipe(strip.Color(0, Full, 0), 50); // Green
  colorWipe(strip.Color(0, Full, Full), 50); // Cyan
  colorWipe(strip.Color(0, 0, Full), 50); // Blue
  colorWipe(strip.Color(Full, 0, Full), 50); // Magenta
  rainbowCycle(10,2);//10 rainbow cycles
  colorWipe(0,5);//Black
}

Hope you find this code useful. Have a very Merry Christmas and a blessed new year.