This Remote Control Easter Egg Has 16,581,375 Colors.

18,933

72

21

Introduction: This Remote Control Easter Egg Has 16,581,375 Colors.

This Easter egg has 16,581,375 colors.  The color can be changed using any button on any TV, DVD, or VCR remote.  It fills me with delight.

This project uses an RGB LED to produce colors inside a white egg.  The brain of the random selection is an ATMEL Attiny85 microcontroller programmed with an Arduino board.  The part that communicates with the remote controls is a phototransistor sensitive to the wavelength of light and modulation (carrier frequency) of the remote.  

Step 1: Getting What You Will Need:

1 Attiny85 (or 45) microcontroller (digikey #ATTINY85V-20PU-ND )
1 common anode RGB LED (I got mine from adafruit.com (#159))
3  220 ohm 1/4 watt resistors
1  Infrared (IR) phototransistor (you can order one from adafruit.com (#157) or salvage one.)
3 or 4 1.4 volt batteries  (I got these at the drugstore (for hearing aids))

The IR phototransisitor that I used in this project came from the front panel of a lifeless VCR.  If you are ordering other parts, it is cheap to buy a new one ($2?), but I actually do get a kick out of digging as many parts as I can out of old machines.

The resistors only serve to limit current to the LED, so anything from 180 to 560 would really be OK, just use 3 of the same value.

If the RGB LEDs you find are common cathode, connect the common pin to ground, obviously, but I think the code will still work, just producing the chromatic compliment of whatever you would get from a common anode part.  I think.  

For this circuit, I stacked up 4 little batteries and got about 5.4 volts.  In the past, I have run projects using the Attiny85 and RGB LEDs with a 3 volt coin cell (CR2032 type), but the IR transistor in this project seems to really want 5 volts to run properly.

Step 2: Programming the Microcontroller.

I used the code and method from the MIT high/low tech blog (http://hlt.media.mit.edu/?p=1706) to turn my Arduino into an Attiny programmer and upload programs to an Attiny85 microcontroller chip.  I used the Attiny chip because it is smaller than the Arduino Atmega 328 chip (so it will fit into a chicken egg) and it is so inexpensive ($1.30) I did not feel bad about having it being a single use part.

I put together a programming shield with perf-board just to streamline things, but you can do all of this programming with a breadboard and wire leads.  Follow the directions from the MIT site to add the ArduinoISP sketch to your Arduino IDE. Once that is downloaded and installed:

1.  Plug your Arduino board into your computer and upload the ArduinoISP sketch from the Examples menu.
2.  Use your breadboard and leads or ISP shield to connect the Attiny chip to the Arduino.
3.  Open a new window in the Arduino IDE and paste the RemoteEgg sketch (below).
4.  Save the sketch.
5.  From the IDE menu, select Tools>Board>"Attiny85(w/Arduino as ISP)"
6.  Upload the sketch.  (This time, the upload will go to the Attiny.)

-----------------------------------------------------------------------------------------------------------------

// This is the RemoteEgg program intended for use with an
// Attiny85 microcontroller.  by Kendrick Goss
// This program is in the public domain.
// This sketch waits for an IR pulse from a remote control
// and then randomly changes the color of an RGB LED

int ledPinRED = 2;    // LED on digital pin 2
int ledPinGREEN = 1;  // LED on digital pin 1
int ledPinBLUE = 4;   // LED on  digital pin 0
int inPin = 0;   // the input pin for the IR phototransistor
int randRED = 0;
int randGREEN = 0;
int randBLUE = 0;

void setup() {
  pinMode(inPin, INPUT);    // declare IR phototransistor as input
}

void loop(){
  while(digitalRead(inPin) != LOW) {};  // read input value

    randRED = random(255); // picking a random number
    randGREEN = random(255); // between 1 and 255
    randBLUE = random(255);

    analogWrite(ledPinRED, randRED);        
    analogWrite(ledPinGREEN, randGREEN);        
    analogWrite(ledPinBLUE, randBLUE);        
    delay(100);  // de-bounces the input so it does not zoom
                 // through a zillion colors with every button click   
  }

Step 3: The Circuit.

Plug the Attiny and the other parts into the breadboard and supply 5 volts.  Keep in mind that the pin number on the chip (counted 1 through 8 counterclockwise from the top of the chip) do not match up to the pin numbers in the program code.  See the diagram for set up.  It is important to check the circuit out on the breadboard first - just to make sure the program uploaded and to make sure you like the way it works. 

The circuit should be responsive to a remote control click.  The way this works is that the IR phototransistor is actually tuned to watch for pulses of light flashing at 38kHz.  This is the frequency remotes use and makes the whole system remarkably sensitive, even through the egg shell.  (For more information on this, see ladyada's write up here: http://www.ladyada.net/learn/sensors/ir.html) We are not actually de-coding any of the pulses here - all the button pushes mean the same thing to this circuit ("Go!").  The phototransistor is powered by the batteries and outputs power to the OUT pin when it detects the remote flashing at 38 KHz.  While the pin connected Attiny has no volts (is LOW), it does nothing.  When it goes HIGH (power delivered), it cues the Attiny to change the color of the LED.

Step 4: Solder It Together in Some Sort of Tall and Compact Shape.

This construction method is sometimes referred to as "dead bug" because, of course, the Attiny appears to be done in, on its back with its feet up in the air.  PAY SPECIAL attention, when soldering something together like this, that you get the pin numbers right - they are backwards when the chip is upside down.

Don't rush it, keep in mind the parts are heat sensitive, AND breath a sigh of relief at the end to see that it all still works!

Step 5: Empty the Egg

Poke a hole in the bottom of a white egg.  Shake it until the insides come out.  Oh, and: do this over a sink.  Widen the hole with scissors to fit the light assembly. 

To give the whole assembly some weight and a place to stand, I soldered a short piece of copper pipe onto a penny.  The stacked up batteries (wrapped up with tape) are inside the tube,

Step 6: Assemble It and Click Through the Colors.

Leaving this by the TV is fun, for a while.  Happy Easter!

Be the First to Share

    Recommendations

    • For the Home Contest

      For the Home Contest
    • Make It Bridge

      Make It Bridge
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge

    21 Comments

    0
    triumphman
    triumphman

    8 years ago on Introduction

    No way you counted the colors, besides there are not that many ! You can't fool us! Eggzactly!

    0
    Gnocchi_the_cat
    Gnocchi_the_cat

    Reply 2 years ago

    No, I think they're right if RGB has a range of 255 for each color then 255x255x255 or 255 cubed is 16581375.

    0
    Cyberlizer
    Cyberlizer

    Reply 6 years ago

    Colors in a computer are represented with 3 values, red, blue, and green. Each of them have 255 possibilities. 255^3=16,581,375. So yes, there are, in fact, that many possible colors. Math, not COUNTING OUT every color.

    0
    csochacki
    csochacki

    9 years ago

    How long the works on these batteries?

    0
    Snipe8200
    Snipe8200

    10 years ago on Introduction

    How did you get 16 and a half million colours!?? :P

    0
    SpagoPizza
    SpagoPizza

    Reply 10 years ago on Introduction

    This seems odd to me as well . And also , how did you count it all ?

    0
    kendrickgoss
    kendrickgoss

    Reply 10 years ago on Introduction

    Each of the LED colors can be powered by the microcontroller from "0" no power, up to 255 "full power." Mixing the 3 colors at different values results in all the colors of the spectrum. SO: 255 x 255 x 255 = 16,581,375 color combinations. Practically speaking, we can not possibly tell a difference between combination 255-116-83 and 255-116-82, for instance, so in a sense this is an exaggeration. When writing this code, I actually wondered if the apparent variety would actually be increased if I had the colors changed by 10s, that is 25 x 25 x 25 = 15,625 colors. In this case the differences between the similar colors with be greater. But I have not tried this.

    0
    bgepp1
    bgepp1

    10 years ago on Step 6

    so how does the TV controller control? It would be great to see a video of this egg in action

    0
    kendrickgoss
    kendrickgoss

    Reply 10 years ago on Introduction

    The TV controller sends out infrared light in little pulses at a rate of 38,000 times a second, hence, 38kHz. To control a TV (or DVD player, or other) to do a specific thing, it sends these little pulses out in timed packets - it's not Morse code, but similar idea. This circuit (specifically the IR sensor part) watches for 38kHz, but there is no decoding of the information going on. Think of a circuit that is noise activated, rather than voice recognition. A video is a great idea! I will try figure out how to do that. Thanks for the comment!
    P.S. Your cell phone camera can see parts of the light spectrum that you can not. One cool thing to do: turn on your cell phone camera and point the remote at the lens and press any button. You can see the flashing packets! (This is also a good way to judge the battery strength of your remote!)

    0
    bgepp1
    bgepp1

    Reply 10 years ago on Introduction

    whoa that's cool, I just tried the cell phone trick and it worked! Very cool stuff. thanx

    0
    Awesome-aniac
    Awesome-aniac

    10 years ago on Introduction

    I have just started using Attinys and this would be a great project to make. Once I learn C (I only know a different language) I could build off of the code that you have posted. Good job.

    0
    kendrickgoss
    kendrickgoss

    Reply 10 years ago on Introduction

    Thanks! I really learned most of what I know by buying a book and just plowing into a project I had in mind. I am sure that someone which greater expertise in Arduino or Processing (or electrical engineers looking at the schematic!) could find many ways to improve it. I look forward to any riffs you have on this one!

    0
    Krayzi99
    Krayzi99

    10 years ago on Step 6

    I'm sure this would work in a plastic easter egg, too. Only problem is mine are already covered

    0
    kendrickgoss
    kendrickgoss

    Reply 10 years ago on Introduction

    I have seen LEDs in plastic and real eggs and they seem to work. The advantage with the white egg is that it is white. I tried this in a brown egg, but it simply blocked out rather than diffused the light. Pick a neutral color I guess?

    0
    Krayzi99
    Krayzi99

    Reply 10 years ago on Introduction

    Also, just noticed i said "covered" instead of "colored". sry for doubly post