Tag Archives: solar cell

Controlling a Dollar Store Solar Dancing Elephant

By now you’ve almost certainly seen those little dancing toys that move when their solar cell gets illuminated. The things fairly well litter the “everything in here is yours for just one stinking dollar” stores. I’m not going to disparage them as toys – to be honest with you, I think some of them are pretty entertaining.

Then again, when have I ever not dismantled one of my toys?

The goal here is to take a solar dancing elephant and hook it up to a computer. When something interesting happens in reality, the elephant starts wagging its ears up and down. I had thought about using it as an email alarm, but that’s just depressing. Instead, I think I’ll scrape the current weather off of the NWS and make it dance in response to something like temperature or rainfall rate. Elephants should get excited when I rains, I guess.

Step one is to crack the elephant open. What really bothers me is that some day, someone is going to arrive on this page after they googled exactly that phrase. Crack the Elephant Open. The mind boggles.

_DSC0352

Anyway, with your elephant nicely bisected, note that the solar cell and some electronics are in the top half of the shell, and the lower half of the widget is all moving parts. The ears are pretty finely counterweighted.  It doesn’t take much force to get them moving. This is a good thing because that solar cell isn’t going to make a lot of power (milliwatts, maybe? ) and the electromagnet that it operates isn’t very big. Incidentally, the astute observer will note that there is a tiny, tiny bare die chip under epoxy on the circuit board, and that the coil is connected to it through something that looks like 40ga wire – aka “man! that’s some awfully fine wire there!” So do be careful.  If you break that wire, you’re pretty much out your one dollar.

_DSC0358

Next step – clip the wires right at the solar cell (red one is positive, natch) and connect a long-ish two conductor wire to each of the leads going to the board. This is what you need to power your elephant. The cell on there makes about half a volt, but I’ve put five volts across the circuit with no ill effects. Evidently, the design has some wide tolerances. 🙂

Final step – connect the wires to the ground (pin 18 was as convenient as any) and to a data pin (pin 2 is the least significant bit) on a connector for a parallel port. I added a parallel 100 ohm resistor that I really didn’t need, but I figured it might help the elephant live longer. Then finally all you have to do is find an old-school laptop with a parallel port and plug it in. A few lines of C, and voila!  You’re (announcer voice) controlling elephants from Linux.  And seriously, once you’ve done that, the rest of your day is going to be all downhill.

OLYMPUS DIGITAL CAMERA

Controlling things comes down to manipulating the parallel port (and no, this will not work through a USB-to-Parallel converter).

#include<stdlib.h>
#include<stdio.h>
#include<sys/io.h>

void main(int argc, char **argv){
unsigned int value=0;
if (argc > 1) {
sscanf(argv[1],"%x",&value);
}

printf("%x\n",value);

int port=/*  0x378 */ 0x3bc;
int res = ioperm(port,5,1);  /* allow access to io port plus next 5 addrs */
outb(value,port);
outb(0x01,port+2);
sleep(1);
outb(0x00,port+2);
printf("End\n");
}

And that’s all there is to it.