Introduction: Upgrading a Smart Pals Learning Bear
A friend gifted us a teddy bear with two embedded buttons at our housewarming, presumably for our toddler. A kind gesture, but as it turns out, once the button for either English or Spanish alphabet is pressed, it sings the entire thing, and the only way to turn it off is to rip open the back of the bear and flip the switch on the little white box they included. My first thought was, "Great! I'll try to circuit bend this!" But after opening up the electronics box, I didn't see any timing circuitry and most of the components were covered in that hardened black goop. So, I decided to make it into a wireless sound and light controller.
Materials:
Smart Pal (or other electronic toy with buttons)
FIO Arduino and Battery
3-Axis Accelerometer
XBee Radio for FIO
XBee Radio with Serial or USB connection for computer *
assorted wires, headers, sockets
lead-free solder
soldering iron
helpful spouse or friend to watch the kids while you're working on this
Computer with Pure Data installed to generate sound
SaikoLED Saiko5 fixture or other LED setup to generate light
I had these parts lying around from other projects, and the bear was a gift. If you bought all the parts for the wireless system new from Spark fun, it would probably cost $150, which is less than some electronic toys but still a lot!
* I am going to be investigating using the Seeedstudios Bluetooth Bee instead of XBee radios which would drop the cost by $50. If anyone knows of a cheaper accelerometer (short of etching your own board) please let me know in the comments.
Materials:
Smart Pal (or other electronic toy with buttons)
FIO Arduino and Battery
3-Axis Accelerometer
XBee Radio for FIO
XBee Radio with Serial or USB connection for computer *
assorted wires, headers, sockets
lead-free solder
soldering iron
helpful spouse or friend to watch the kids while you're working on this
Computer with Pure Data installed to generate sound
SaikoLED Saiko5 fixture or other LED setup to generate light
I had these parts lying around from other projects, and the bear was a gift. If you bought all the parts for the wireless system new from Spark fun, it would probably cost $150, which is less than some electronic toys but still a lot!
* I am going to be investigating using the Seeedstudios Bluetooth Bee instead of XBee radios which would drop the cost by $50. If anyone knows of a cheaper accelerometer (short of etching your own board) please let me know in the comments.
Step 1: Remove Annoying Alphabet Box
Open up the velcro on the back of your bear.
Pull out the white box far enough to find all four wires going into the body of the bear.
These go to the bear's foot-buttons.
In my bear, each pair of wires was a different color. That made it easier to tell them apart.
Pull out the white box far enough to find all four wires going into the body of the bear.
These go to the bear's foot-buttons.
In my bear, each pair of wires was a different color. That made it easier to tell them apart.
Step 2: Prepare Button Wires for Re-purposing
Strip all four wires.
Separate the paired wires so that you have one wire from each button.
Connect two wires together, one from each button, and connect that to an extension wire that will go to the board.
Keep the other pair electrically isolated, so extend them individually if you'd like to make it easier to work with.
----
There are a few ways to make these connections. The most structural and hardest to change later would be to twist and solder each junction. Another option is to use a small wire nut or to tin the ends of the wires (to keep them from fraying) and use jumper cables to connect them to pins on the Arduino.
I chose a hybrid approach. I cut a jumper in half, using the twist and solder method to connect it to the buttons' wires. If later on I feel like experimenting, it's easy to change the connections around on the FIO or even connect them to wires on a protoboard.
Separate the paired wires so that you have one wire from each button.
Connect two wires together, one from each button, and connect that to an extension wire that will go to the board.
Keep the other pair electrically isolated, so extend them individually if you'd like to make it easier to work with.
----
There are a few ways to make these connections. The most structural and hardest to change later would be to twist and solder each junction. Another option is to use a small wire nut or to tin the ends of the wires (to keep them from fraying) and use jumper cables to connect them to pins on the Arduino.
I chose a hybrid approach. I cut a jumper in half, using the twist and solder method to connect it to the buttons' wires. If later on I feel like experimenting, it's easy to change the connections around on the FIO or even connect them to wires on a protoboard.
Step 3: Connect Components to Funnel
If you are using breakaway headers, now is the time to attach them to your Funnel and/or accelerometer breakout boards.
I wanted to save space, so I connected the accelerometer directly to the FIO via headers on the analog input pins, and routed wires to power and ground.
Connections for the accelerometer are as follows:
breakout pins - FIO pins
X - A5
Y - A6
Z - A7
GND - GND
VCC - 3V3
Connections for the button are as follows:
button wires - FIO pins
left button, wire1 - 3V3
right button, wire1 - 3V3
left button, wire2 - D7
right button, wire2 - D8
BEFORE INSTALLING THE XBEE IN THE FUNNEL SOCKET
Configure the XBee that will be inside the bear as an "End device"
Configure the XBee connected to the computer as the Coordinator
More detailed instructions are here:
http://funnel.cc/Hardware/FIO
This doesn't matter much for the serial communication, but it does matter for the wireless programming.
Yes, you can reprogram your bear without opening it up!
I wanted to save space, so I connected the accelerometer directly to the FIO via headers on the analog input pins, and routed wires to power and ground.
Connections for the accelerometer are as follows:
breakout pins - FIO pins
X - A5
Y - A6
Z - A7
GND - GND
VCC - 3V3
Connections for the button are as follows:
button wires - FIO pins
left button, wire1 - 3V3
right button, wire1 - 3V3
left button, wire2 - D7
right button, wire2 - D8
BEFORE INSTALLING THE XBEE IN THE FUNNEL SOCKET
Configure the XBee that will be inside the bear as an "End device"
Configure the XBee connected to the computer as the Coordinator
More detailed instructions are here:
http://funnel.cc/Hardware/FIO
This doesn't matter much for the serial communication, but it does matter for the wireless programming.
Yes, you can reprogram your bear without opening it up!
Step 4: Connect the Battery, Velcro Up the Bear
Thats it for the hardware!
If you had a project box that was small enough to fit in the bear, now would be the time to put the components into it. If you used jumper cables, routing through small holes drilled in a case would be easy. I used a plastic bubblewrap bag. I thought about using a static-proof bag, but I was afraid the conductivity would mess with the sensing circuitry, and the ICs are pretty far away from the bag itself.
A plastic bag has the added benefit that if your child starts pulling out the electronics, you'll hear the crinkle noises. With bubble wrap, perhaps he'll even get distracted from the potentially dangerous lithium battery! A better option would be a light sensor that sounds an alarm when the back is opened. Make sure the alarm is not too fun and exciting or the kids'll be opening it all the time!
If you had a project box that was small enough to fit in the bear, now would be the time to put the components into it. If you used jumper cables, routing through small holes drilled in a case would be easy. I used a plastic bubblewrap bag. I thought about using a static-proof bag, but I was afraid the conductivity would mess with the sensing circuitry, and the ICs are pretty far away from the bag itself.
A plastic bag has the added benefit that if your child starts pulling out the electronics, you'll hear the crinkle noises. With bubble wrap, perhaps he'll even get distracted from the potentially dangerous lithium battery! A better option would be a light sensor that sounds an alarm when the back is opened. Make sure the alarm is not too fun and exciting or the kids'll be opening it all the time!
Step 5: Funnel IO (Arduino) Programming
Download Arduino IDE if you don't already have it. It should come with FTDI drivers if you need them.
Plug in the XBee radio breakout to the computer.
A new serial port should show up in your Arduino IDE's menu if you have the FTDI drivers (in the usb case).
Otherwise, just select the serial port to which it is connected.
For the newer FIO boards, there is an option for "Arduino FIO" under "boards."
My funnel is a bit older, so I needed to choose "Arduino Pro or Pro Mini (3.3V 8Mhz) with ATMega168."
In the code that follows, I've provided some debugging options to turn on an LED when a button is pressed (you'll need to open the bear to see it). Uncomment both the pinMode line and the if statements near the bottom to use it.
Here is the code:
file: remoteBear.pde
// Arduino Funnel code for ADXL335 triple axis accelerometer sensor.
// Use with setting 'Arduino Pro or Pro Mini (3.3V 8Mhz) with ATMega168'
char str[512];
void setup() {
pinMode(7,INPUT);
pinMode(8,INPUT);
// pinMode(13, OUTPUT);
Serial.begin(19200);
}
void loop() {
byte x = analogRead(7)/4;
delay(10);
byte y = analogRead(6)/4;
delay(10);
byte z = analogRead(5)/4;
byte d1 = 1;
byte d2 = 1;
if (digitalRead(7) == HIGH){
d1 = 2;
}
if (digitalRead(8) == HIGH){
d2 = 2;
}
/*if (d2+d1 >= 1)
digitalWrite(13, HIGH); // set the LED on
else
digitalWrite(13, LOW); // set the LED on
*/
sprintf(str, "%c%c%c%c%c", x, y, z,d1,d2);
Serial.println(str);
delay(80);
Plug in the XBee radio breakout to the computer.
A new serial port should show up in your Arduino IDE's menu if you have the FTDI drivers (in the usb case).
Otherwise, just select the serial port to which it is connected.
For the newer FIO boards, there is an option for "Arduino FIO" under "boards."
My funnel is a bit older, so I needed to choose "Arduino Pro or Pro Mini (3.3V 8Mhz) with ATMega168."
In the code that follows, I've provided some debugging options to turn on an LED when a button is pressed (you'll need to open the bear to see it). Uncomment both the pinMode line and the if statements near the bottom to use it.
Here is the code:
file: remoteBear.pde
// Arduino Funnel code for ADXL335 triple axis accelerometer sensor.
// Use with setting 'Arduino Pro or Pro Mini (3.3V 8Mhz) with ATMega168'
char str[512];
void setup() {
pinMode(7,INPUT);
pinMode(8,INPUT);
// pinMode(13, OUTPUT);
Serial.begin(19200);
}
void loop() {
byte x = analogRead(7)/4;
delay(10);
byte y = analogRead(6)/4;
delay(10);
byte z = analogRead(5)/4;
byte d1 = 1;
byte d2 = 1;
if (digitalRead(7) == HIGH){
d1 = 2;
}
if (digitalRead(8) == HIGH){
d2 = 2;
}
/*if (d2+d1 >= 1)
digitalWrite(13, HIGH); // set the LED on
else
digitalWrite(13, LOW); // set the LED on
*/
sprintf(str, "%c%c%c%c%c", x, y, z,d1,d2);
Serial.println(str);
delay(80);
Step 6: PureData Programming
Download Pd-extended. Pure Data is a cross-platform visual programming language, much like MaxMSP.
Below I've attached a simple serial receive patch. Use it to ensure you are getting and unpacking data from the FIO, then download this patch to see an example of how the audio and/or light outputs work.
For light output, you will need an OSC-compatible light and the MrPeach extension pack for PureData. MrPeach IS included in pd-extended, but I had to enable it by adding the path to the library, adding 'mrpeach' to the list of extensions to load on startup, and restarting PD.
The audio output is a simple pitch shifted tone based on the example audio output code PD provides. PD is great in that you can right-click any element and see help where an example of the element is used. That's where I got the audio patch, it is not particularly complex, but many of the elements send messages to each other in a way not visible unless you right click on an element to view it's properties. Message-passing is a great tool in a language, but it could be a little more visible....
The light output is a simple call to Open Sound Control output over the network. The Saiko 5 light I have makes it easy by setting up an ad-hoc wireless network for the computer to connect to. Saiko 5 is open source and open hardware, based on an Arduino, so it is completely hackable.
Here is the serial receive example which should not require any extensions:
file: SimpleSerial.pd
#N canvas 527 99 450 300 10;
#X obj 45 -176 comport 3 19200;
#X floatatom 28 -56 5 0 0 0 - - -;
#X floatatom 85 -55 5 0 0 0 - - -;
#X floatatom 142 -56 5 0 0 0 - - -;
#X floatatom 205 -55 5 0 0 0 - - -;
#X msg 40 -202 close;
#X msg 102 -197 open 3;
#X obj 78 -95 unpack f f f f f;
#X obj 45 -155 sel 10 13;
#X obj 79 -127 zl group 22;
#X floatatom 269 -55 5 0 0 0 - - -;
#X connect 0 0 8 0;
#X connect 5 0 0 0;
#X connect 6 0 0 0;
#X connect 7 0 1 0;
#X connect 7 1 2 0;
#X connect 7 2 3 0;
#X connect 7 3 4 0;
#X connect 7 4 10 0;
#X connect 8 1 9 0;
#X connect 8 2 9 0;
#X connect 9 0 7 0;
Below I've attached a simple serial receive patch. Use it to ensure you are getting and unpacking data from the FIO, then download this patch to see an example of how the audio and/or light outputs work.
For light output, you will need an OSC-compatible light and the MrPeach extension pack for PureData. MrPeach IS included in pd-extended, but I had to enable it by adding the path to the library, adding 'mrpeach' to the list of extensions to load on startup, and restarting PD.
The audio output is a simple pitch shifted tone based on the example audio output code PD provides. PD is great in that you can right-click any element and see help where an example of the element is used. That's where I got the audio patch, it is not particularly complex, but many of the elements send messages to each other in a way not visible unless you right click on an element to view it's properties. Message-passing is a great tool in a language, but it could be a little more visible....
The light output is a simple call to Open Sound Control output over the network. The Saiko 5 light I have makes it easy by setting up an ad-hoc wireless network for the computer to connect to. Saiko 5 is open source and open hardware, based on an Arduino, so it is completely hackable.
Here is the serial receive example which should not require any extensions:
file: SimpleSerial.pd
#N canvas 527 99 450 300 10;
#X obj 45 -176 comport 3 19200;
#X floatatom 28 -56 5 0 0 0 - - -;
#X floatatom 85 -55 5 0 0 0 - - -;
#X floatatom 142 -56 5 0 0 0 - - -;
#X floatatom 205 -55 5 0 0 0 - - -;
#X msg 40 -202 close;
#X msg 102 -197 open 3;
#X obj 78 -95 unpack f f f f f;
#X obj 45 -155 sel 10 13;
#X obj 79 -127 zl group 22;
#X floatatom 269 -55 5 0 0 0 - - -;
#X connect 0 0 8 0;
#X connect 5 0 0 0;
#X connect 6 0 0 0;
#X connect 7 0 1 0;
#X connect 7 1 2 0;
#X connect 7 2 3 0;
#X connect 7 3 4 0;
#X connect 7 4 10 0;
#X connect 8 1 9 0;
#X connect 8 2 9 0;
#X connect 9 0 7 0;
Step 7: That's It, We're All Done!
Here is my son Liam, demoing it for me:
He was a very good actor, but was bored with the toy by the end of the take. He's also seen it before. Oh well, guess I'll need to improve the sound and light responses to make it more fun!
Yay! My first Instructable! Thanks for reading!
He was a very good actor, but was bored with the toy by the end of the take. He's also seen it before. Oh well, guess I'll need to improve the sound and light responses to make it more fun!
Yay! My first Instructable! Thanks for reading!