2023 Group 10 – Bo The Bear

Ayana Bazzy, Riva Lakkadi, and Safiya Menk

Project Overview:
No child loves anything more than havign a personal stuffed animal. Most stuffed animals are inanimate, but Bo the Bear is an interactive teddy bear that engaged with its owner to make them feel loved and happy. Bo is a comfort best friend to a designated child, providing them with loyal protection and support in times of need!

Project Brief:
Bo the Bear comes with two key tags, a blue round tag and a white card. The blue tag is the friendly tag and the white tag is the enemy tag. The child owner of the bear keeps the blue tag. When they scan the blue tag to the bear’s chest, the eyes will light up green, happy music will play, and the bear’s right arm will move. Since the child keeps the blue tag, if anyone else tries to play with the bear by using the white tag, the eyes will turn red, angry music will play, and both arms will flap around.

Our Aims:
We intended to create a product that would engage with the child through three primary interactions: audio, visual, and movement. These are some of the interactions that children tend to recognize and understand best. Some light colors have universal meanings that children can understand, and lights also appeal to a child’s eye. Children also love hearing sound and are often attracted to it, so we wanted Bo to also play music. Lastly, movement is a form of interaction that will make the child believe that the bear is alive and real, so they will truly feel as if the bear is a real-life friend! We also wanted Bo to only be loyal to its owner, so any other person who tries to interact with Bo will receive the same feedback, but it won’t be friendly.

Target Audience:
Bo is created for children ages 3-10. This is the age range where children typically engage with stuffed animals. Children get emotional support from Bo, a play toy, a sleep companion, and unconditional love from Bo.

Project Planning:

Project Task List:

Ayana BazzyPsuedocode for Speakers
Arduino Board 
Bought Teddy Bear
Inserted components into bear
Tested Code
Safiya MenkUpdated document with project progress/updates
Pseudcode for Servos
Arduino Board
Commented code
Tested Code
Finalized Code
Riva LakkadiPseudcode for RFID Tag and LED
Ordered components 
Soldiered wires into RFID Card Reader and RGB LEDs
Arduino Board
Tested Code
GANTT Chart

Brainstorming & Low-fi Prototyping:

Brainstorm

Lo-Fi Prototype

Research:

Because we’ve worked with most of the parts utilized in the project in class, all we had to do was follow the circuit diagram for each part (servo, RGB LEDs, speaker). Linked below is the circuitry for each part:

RGB LED: https://www.instructables.com/How-to-use-an-RGB-LED-Arduino-Tutorial/

Servo: https://learn.adafruit.com/experimenters-guide-for-metro/circ04-wiring

Speaker: https://learn.adafruit.com/experimenters-guide-for-metro/circ06-wiring

However, one of our most difficult struggles was getting the RGB LED to display the appropriate colors. Although we tried to make sure the wiring was okay, we had to take apart the circuitry multiple times to get it to work. We used this video along with following the Professor’s advice to get the RGB LED to work properly

Video to Help Set Up RGB LED

Writing 0 (analogue) to turn a pin on and 255 to turn it on helped us get the appropriate colors to show.

RFID Tag

Because the RFID MFRC522 was unfamiliar to all of us, we had to look at multiple resources detailing how to set it up.

https://www.instructables.com/Use-MFRC522-RFID-Reader-With-Arduino/

Design Decisions:

  • RGB LEDs: We wanted to provide visual feedback to the user as children are easily able to recognize visual signals. We chose to use an RGB LED because it is the best way to be able to display multiple colors onto one LED. We can display red, green, blue, purple, no colors, etc. As green is a universal symbol of friendliness, approachability, and acceptance, we purposely chose to display green to the user when they scan the friendly tag. The bright color will make the child feel welcome, and they will be able to recognize green as a sign of goodness. On the other hand, red is a universal symbol of evilness or anger. Therefore, when someone who is not the child owner tries to scan with the white tag, the eyes will turn red. The person scanning the tag will understand that the bear is angry due to the color of the eyes.
  • Speaker: We wanted to provide auditory feedback to the user as children tend to also interact with sound. We chose to order a speaker from Amazon instead of using the Piezo as our speaker provided more quality noise. When the friendly tag is scanned, happy music plays. The child recognizes that this is a good tune, and they will feel welcomed by the bear. On the other hand, when the enemy tag is scanned, a deeper angry tune is played, which signifies to the user that the bear does not welcome them and that the bear does not want to interact with them.
  • Servo: We wanted to provide motion feedback to the user as motion signals are an additional way of conveying emotion. We chose to use servos as they were the one motion actuators we were familiar with, and we thought they would get the job done. Unfortunately, one of our failures was that we didn’t make it so that the servo would move the entire arm/hand of the bear. We assumed that the servo would be powerful enough to move just the hand, but after inserting it, we realized there was very limited motion. There was also not enough time left to find a way to be able to increase the motion. We thought of attaching something to the bear’s hand so it moves with the sensor, but we weren’t able to carry this action out in time with the available materials. We could improve this by adapting our code to make the servos more powerful and make the motion more visible.

Principles of Interactive Design

  • Feedback: As mentioned above, we provided various forms of feedback to the user to convey the intentions and purpose of Bo.
  • Visibility: Each aspect of the project is visible to the user. The RGB LEDs are inserted into the eyes, the card tags come with the product, and the user can see the speaker and servos. Although they may not be familiar with the speaker and servo, once they start up the product, they will understand what each part does
  • Learnability: Our product is extremely easy to learn to use. We provide instructions with the product that state which key tag belongs to the owner, and we notify them that all they have to do is tap their tag on the bear’s chest. It is also easy for children to just tap a tag onto a bear, so there is no difficulty in executing the action.
  • Efficiency: The user only needs to take one step to make the bear work. All they have to do is scan the tag, and the bear takes over from there

Day By Day Blog Updates

November 15-16:
Group members decided that the Interactive Teddy Bear is our top choice for the final project

November 17-21:
Did background research on the project and decided that the three main functionalities will be the teddy bear’s eyes lighting up (RBG LEDs), the hands of the teddy bear waving (servo motors), and audio feedback (speaker). We found that we could used recycled items for the servo motors, wires, resistors, and RGBs, but we had to buy all the other components.

November 20:
We created a brainstorm diagram that took into consideration the material, aesthetic, consumers, function, cost, safety, environment, and size of our project. We also created a lo-fi prototype in the form of a storyboard detailing the two different states the teddy bear can be in (friendly and unfriendly).

November 25-27:
We bought the RFID tags and speaker from amazon after researching what models would work best with our project

December 4:
We started working with the RBG LEDs but had some difficulty getting the correct colors to show up. After lots of trial and error, we went to the professor for advice and did more research online.

December 5:
The RGB code started working and all the correct colors were lighting up. We also soldered long wires to both RGBs because they needed to reach the board from all the way inside of the teddy bear’s eyes. Next, we got the servo motors and speaker to work in both a friendly mode and an unfriendly mode. For the friendly servo, we moved the right motor back and forth to simulate a hand waving. The unfriendly servos had both motors moving in a frenzy to show that the bear would be upset. For the speaker, we chose a happy tune for the friendly mode and a lower register dark tune for the unfriendly mode.

December 6:
We soldered 8 long wires to the RFID scanner so that it could sit inside of the bear and still reach the board. This took a long time because at first, all the soldered wires were touching each other and the scanner was not working, After going back and forth trying to fix the soldering, we finally got the RFID tag to recognize and scan both the blue and white tags.

December 7-9:
We spend these last few days testing and finalizing our code before the presentation. We initially tested each component separately, so we finally combined the RBG, servo, and speaker code and got rid of any bugs we found.

December 10:
We put the RBG LEDs inside the eyes of the bear, the servo motors inside the arms of the bear, and the RFID tag in the chest of the bear. We decided to leave the speaker outside of the bear so that the user could hear the audio more clearly.

December 11:
We presented our final presentation to the class and demonstrated our interactive teddy bear to the instructors.

Maker Manual:

Tools & Supplies:

  • 1 Arduino Uno
  • 2 Breadboards
  • 6 Resistors 220Ω (Red-Red-Brown)
  • 2 RGB LED lights
  • 2 Servo Motors (X-shaped horns)
  • 1 Speaker (3 Watts)
  • 1 MFRC-RC522 RFID Reader with 2 Tags
  • Wires
  • USB Cable
  • Stuffed Teddy Bear
  • Soldering Iron
  • Scissors
  • Cutting Knife
  • Duck tape

Circuit Diagram:

Building the Final Product:

  1. Soldering the Wires:
    – Solder wires into RFID card reader
    – Solder longer wires for the LEDs to fit into the bear

2. Build the Circuit According to the Diagram:
– the RFID reader should activate the correct LEDs, music and servo motions

3. Stuffing the Bear:
– Slit the back of the bear using a knife cutter/scissors
– Cut small holes into the bear’s eyes for the LEDs to fit in
– Remove the stuffing from the body, arms and most of the head
– Cut small holes into the bear’s hands for the servos to fit in
– Slide each servo into the right arm and attach the horn from the outside through the hole cut
– Restuff the bear’s arms to keep the motors in place
– Carefully slide each LED light into the correct hole and restuff the head to secure the position
– Use duck tape to stick the RFID reader on the bear’s belly and restuff to secure its position

Our Final Product:

Complete Code:

//libraries for the RFID Tag
#inlcude <SPI.h>
#inlcude <MFRC522.h>

//library for the servo
#include <Servo.h>

//create Servo objects for the arms of the teddy bear
Servo rightArm;
Servo leftArm;

//variable for speaker pin
int speakerPin = 6;

//Pins 9 and 10 communicate the RFID tags to the Arduino Board
#define SS_PIN 10
#define RST_PIN 9
MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class

MFRC522::MIFARE_Key key;

// Init array that will store new NUID
byte nuidPICC[4];

//utilized a built in Arduino file called NUID that when you scan tags, it returns the UID of both tags.
String happy_user = “F0 76 80 10”;
String angry_user = “C3 64 1A 03”;
//variable for which user is logged in. there are two options: the user the bear recognizes or the user the bear doesn’t
int loggedIn = 0;

void setup() {
//setupRFID
Serial.begin(9600);
SPI.begin(); // Init SPI bus
rfid.PCD_Init(); // Init MFRC522
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF;
}

//setupRGBLEDs
//left eye
pinMode(A0,OUTPUT);
pinMode(A1,OUTPUT);
pinMode(A2,OUTPUT);
//right eye
pinMode(A3,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A5,OUTPUT);

//setupServo
//left arm
leftArm.attach(3);
//right arm
rightArm.attach(5);

//setupSpeaker
pinMode (speakerPin, OUTPUT);
}

void loop() {
//initialize the state of the bear to neutral. no lights should be on
neutralLights();

//all of this code is used to verify the presence of the correct RFID Tags
// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
if ( ! rfid.PICC_IsNewCardPresent()) //only execute the code if a different card is presented
return;

// Verify if the NUID has been readed
if ( ! rfid.PICC_ReadCardSerial())
return;

Serial.print(F(“PICC type: “));
MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
Serial.println(rfid.PICC_GetTypeName(piccType));

// Check is the PICC of Classic MIFARE type
if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&
piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
Serial.println(F(“Your tag is not of type MIFARE Classic.”));
return;
}

//write whatever is scanned in hex form to the currentState variable. this variable is used later to compare against actual tag name
String currentState = “”;

if (rfid.uid.uidByte[0] != nuidPICC[0] ||
rfid.uid.uidByte[1] != nuidPICC[1] ||
rfid.uid.uidByte[2] != nuidPICC[2] ||
rfid.uid.uidByte[3] != nuidPICC[3] ) {
Serial.println(F(“A new card has been detected.”));

// Store NUID into nuidPICC array
for (byte i = 0; i < 4; i++) {
nuidPICC[i] = rfid.uid.uidByte[i];
}

//Feedback to the serial monitor to ensure that the RFID Tag is scanning
Serial.println(F(“The NUID tag is:”));
Serial.print(F(“In hex: “));
printHex(rfid.uid.uidByte, rfid.uid.size);
Serial.println();
Serial.print(F(“In dec: “));
printDec(rfid.uid.uidByte, rfid.uid.size);
Serial.println();

//takes in the UID read and concatenates each index to the currentState string
for (byte i = 0; i < rfid.uid.size; i++) {
currentState.concat(String(rfid.uid.uidByte[i] < 0x10 ? ” 0″ : ” “));
currentState.concat(String(rfid.uid.uidByte[i], HEX));
}
currentState.toUpperCase();
}
else {Serial.println(F(“Card read previously.”));
// Halt PICC
rfid.PICC_HaltA();
// Stop encryption on PCD
rfid.PCD_StopCrypto1();
}

//compare the currentState against the tag UID and play the appropriate bear mood based on that
if(currentState.substring(1) == happy_user){
Serial.println(“Inside happy state”);
int y = 0;
while (y <2) {
happyLights();
happyMusic();
happyArms();
y+=1;
delay(100);
}
}

else if(currentState.substring(1) == angry_user){
//if bear recognizes user, play happy music, lights, and wave nicely
Serial.println(“Inside angry state”);
//use a loop to increase duration of angry state
int x = 0;
while (x<2) {
Serial.println(x);
angryLights();
angryArms();
angryMusic();
x+=1;
delay(100);
}
}
else {
//this means a tag was not scanned. the bear can remain in a neutral state
Serial.println(“inside neutral state”);
neutralLights();
}
}

// Helper routine to dump a byte array as hex values to Serial.
void printHex(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? ” 0″ : ” “);
Serial.print(buffer[i], HEX); }
}

// Helper routine to dump a byte array as dec values to Serial.
void printDec(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? ” 0″ : ” “);
Serial.print(buffer[i], DEC); }
}

void printLogin(String id){
Serial.println(“You are logged in as “+id+” .”);
}

//SERVO

void angryArms() {
Serial.println(“Angry arms”);
for (int pos = 0; pos <= 90; pos +=15) { // goes from 0 degrees to 90 degrees in steps of 15 degrees
rightArm.write(pos); // write both arms to the position
leftArm.write(pos);
delay(25); // waits 25ms for the servo to reach the position
}
for (int pos = 90; pos >= 0; pos -= 15) { // goes from 90 degrees to 0 degrees
rightArm.write(pos); // write both arms to the position
leftArm.write(pos);
delay(25); // waits 25ms for the servo to reach the position
}
}

void happyArms() {
Serial.println(“Happy arms”);
//only move the right arm to wave
for (int pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees in steps of 1 degree
rightArm.write(pos); // tell servo to go to position in variable ‘pos’
delay(20); // waits 20ms for the servo to reach the position
}
delay(1000);
for (int pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
rightArm.write(pos); // tell servo to go to position in variable ‘pos’
delay(20); // waits 20ms for the servo to reach the position
}
}

//SPEAKER

//function that plays a certain tone
void playTone(int frequency, int duration) {
tone(speakerPin, frequency, duration);
delay(duration); // Wait for the tone to finish before playing the next one
noTone(speakerPin);
}

//function2 that plays a certain tone
void playNote(char note, int duration) {
char names[] = { ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘A’, ‘B’ };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014 };
// play the tone corresponding to the note name
for (int i = 0; i < 7; i++) {
if (names[i] == note) {
tone(speakerPin, tones[i], duration);
}
}
}

//function that plays happy music in happy state
void happyMusic(){
int length = 20; // the number of notes
char notes[] = “EDCDEEEDDEFGGGFEEDDD “; // a space represents a rest
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 4 };
int tempo = 300;
for (int i = 0; i < length; i++) {
if (notes[i] == ‘ ‘) {
delay(beats[i] * tempo); // rest
} else {
playNote(notes[i], beats[i] * tempo);
}
// pause between notes
delay(tempo / 2);
}
}

//functiont that plays angry music in angry state
void angryMusic(){
playTone(220, 300); // A4
playTone(220, 300); // A4
playTone(220, 300); // A4
playTone(185, 300); // F4
delay(100);
playTone(196, 300); // G4
playTone(196, 300); // G4
playTone(196, 300); // G4
playTone(174, 300); // B4
delay(500); // pause before playing again
}

//LEDs

void happyLights(){
Serial.println(“Initializing happy lights…”);
//left eye
analogWrite(A0,255);
analogWrite(A1,0);
analogWrite(A2,255);
//right eye
analogWrite(A3,255);
analogWrite(A4,0);
analogWrite(A5,255);
}

void angryLights(){
Serial.println(“Initializing angry lights…”);
//left eye
analogWrite(A0,0);
analogWrite(A1,255);
analogWrite(A2,255);
//right eye
analogWrite(A3,0);
analogWrite(A4,255);
analogWrite(A5,255);
}

void neutralLights(){
//right eye
//Serial.println(“Initializing neutral lights…”);
analogWrite(A0, 255);
analogWrite(A1,255);
analogWrite(A2,255);
//left eye
analogWrite(A3,255);
analogWrite(A4,255);
analogWrite(A5,255);
}

Limitations

  • All of the wires and board stick out of the bear, so the bear isn’t cuddly friendly
  • Aesthetic shortcomings due to the wiring
  • Limited motion due to ineffective attachment of the servos. We could have placed the servos more effectively or tried one of various methods in order to make it so that the servo moves the entire bear’s hands/arms.

Suggestions

  • Rip out a bit of the bear’s paw and attach it to the Servo so the actual hands move
  • Get a bigger bear so that all of the wiring and the boards can fit inside
  • Add more features such as talking, dancing, and customization to the child