Sunday 11 March 2012

Teddy bear prototype

I am developing the teddy bear prototype with a light sensor to detect presence. The next stage after this will be to incorporate sound. For this i have purchased an MP3 player to hack (with removable SD card and integrated speakers), transistors and a 9V battery pack to make the second arduino portable. This tutorial has provided some inspiration on MP3 hacking but it should be achievable with transistors and a few pins on the arduino. A new soldering iron will be used and new jumper wires have been ordered to allow the extension of the components. Also needed are some 560ohm resistors which can be bought from Maplins.

Functional Requirements:

  1. Sense Presence
  2. Communicate with other xbee device
  3. Indicate response in other xbee device
I have purchased two inexpensive teddy bears and have carefully unpicked the threads from the back of both teddy bears. Some stuffing has been removed to allow space for the arduinos to be placed inside. I developed a quick architecture on paper to illustrate how the system would work and provide visual reference.

Below: teddy bears.



 

The next step is setting up new code on one of the arduino boards to accept input from the light dependant resistor which had previously been commented out. I am going to set up a two-way system and have drawn an architecture for it. I am going to test push button (active sensing) versus LDR (passive sensing) on both devices. In one device there will be an on/off switch to indicate whether the person is present.

Note: when developing this system I noticed the problem of crossed wires in the momentary switch. All exposed components should be insulated to prevent this.

The first thing i did was add LEDs to the project and write code to test them. Once this code was running correctly i then put the LDR (light sensor) in the right place.

Note: A code has to be applied to this project. Green LEDs will indicate that that a person is present at the remote location (green="go" or "everythings ok" so naturally this makes most sense). The red light will be hidden at the bottom of the bear for the users to double check that the system is actually up and running. I have decided to make the LEDs blink to help them draw more attention to it.

I tested the LDR on a single board, and once it was working correctly I then incorporated it into the xBee system.

First problem: As soon as the LDR was incorporated into the system, the serial communication became buggy and slow. As soon as the LDR was removed from the system it worked correctly. This is going to be replaced with a push button for the prototype just to get the system working properly and then new methods will be tested.

I need to put an extra button on the second board to act as a presence indicator to replace the LDR. This was tested on a single board with LED indicator code. Then this code was replaced with serial output code.

Note: Always ensure that there is a delay behind any input switch to avoid overwhelming the serial port.

Second problem: the serial monitors have started displaying random numbers and characters when they weren't before. The usual fixes (baud rate, sending valid characters) aren't working so i am going to presume that it is mostly likely due to the fact that the xBees have now been on for nearly 5 hours and may be slightly overheating.

To compensate for this the code has been changed slightly which has meant that the second teddy bear will not have a lighting indicator. For the purposes of this prototype this will suffice as it is a code not a hardware problem.

Below: xBee wiring.


The push buttons are currently momentary (holding them closed indicates presence).

I placed one of the boards inside one of the teddy bears. Once the new soldering iron arrives both will be placed inside. For now i will have to do some more reading on serial communication to understand some of the problems in the system.

Below are some images and videos of this prototype. The pushbutton was placed in the bears hand. On the rear of the bear a red light indicates that the bear is sending data. The green light may placed in the other hand.

What ive noticed with this prototype are some interesting possibilities for different types of presence indicators. It may not be likely that the users would see the light, and perhaps vibration or sound should be used instead. Also, the pushbutton has to be held down at the moment. This could be incorporated into a 'hug' detector, but in terms of interaction is it flawed: the user probably wouldnt want to hold onto the teddy bear in such a specific way for the entire time.

Thinking of a context of use, this could be useful for parents in different time zones who may not be able to make bedtime phone calls as they're at work. What this would allow is a form of interaction that doesnt prevent users from doing their work. Early conversations with users indicate that this may not just be used at bedtime, and parents may not necessarily have to be particularly far away. It could be used by younger children coming home from nursery in the early afternoon or for multiple scenarios. The system is highly flexible, and user testing is the only way forward from here. The teddy bear prototype will be developed further this week into a fully functioning prototype that is not connected to a PC and then introduced to users as a fully functioning 'thing'. This should spark conversation.

This is the prototype so far:

Front: Teddy is a little lopsided, but its hand is well padded. A larger pushbutton could be useful. I padded around the pushbutton before inserting into the arm cavity to keep it secure. It worked quite well but is a little 'fiddly'. Plates could be placed above and below is to increase the area of the push surface.


This is the padded push button.


The front of the teddy bear system. Note the green light going on when the arm is pushed. It is a rapidly flickering light, but the camera shows it a little slower than it is.


The rear of the teddy bear system. Note the red LED flickering.



This is the code so far:

Arduino 1


#define VERSION "1.00a0"
int BELL= 11;
int REMOTEINDICATOR= 7;
int BUTTON = 2;

void setup() {
  pinMode(BUTTON, INPUT);
    pinMode(BELL, OUTPUT);
 pinMode(REMOTEINDICATOR, OUTPUT);
  Serial.begin(9600);
}

void loop() {
 //      digitalWrite(BELL, HIGH);
char s2 = Serial.read();  
  // send a capital D over the serial port if the button is pressed
  if (digitalRead(BUTTON) == LOW) {
    Serial.print('D');
    delay(10); // prevents overwhelming the serial port i increased the delay
}
   //        digitalWrite(BELL, HIGH);

  if (Serial.available() > 0) {
 //   Serial.print(s2);
    if (Serial.read() == 'K'){
      //ring the bell briefly
            Serial.print('k');
     digitalWrite(REMOTEINDICATOR, HIGH);
     delay(10);
     digitalWrite(REMOTEINDICATOR, LOW);

    }

    if (Serial.read() == 'H'){
      //ring the bell briefly
     digitalWrite(BELL, HIGH);
     delay(10);
     digitalWrite(BELL, LOW);
  //   delay(10);
 //     Serial.print('k'); response code - develop later
    }
  }
}

Arduino 2


int buttonState = 0;         // variable for reading the pushbutton status
#define VERSION "1.01"
int REMOTEINDICATOR = 8;
int BELL = 5;
char val;
int lightsetting = 400;
int BUTTON = 6;
//int photocellPin = 0;
//int photocellReading;

void setup() {
  pinMode(BELL, OUTPUT);
    pinMode(BUTTON, INPUT);
    pinMode(REMOTEINDICATOR, OUTPUT);
  Serial.begin(9600);

}

void loop() { 
    buttonState = digitalRead(BUTTON);
    
    if (buttonState == LOW) {   
    Serial.print('H');
      delay(10);  
    // turn LED on:    
//    digitalWrite(BELL, HIGH);  
  } 
  else {
    // turn LED off:
//    digitalWrite(BELL, LOW); 
   //   Serial.print('M');
  //    delay(10);
  }
//  photocellReading = analogRead(photocellPin);
  char s2 = Serial.read();
 /* 
  if(photocellReading<lightsetting) {
  //  Serial.println(photocellReading);
   Serial.print('P');
   delay(100);
 //  digitalWrite(BELL, HIGH);
  }
  
  if(photocellReading>=lightsetting) {
//   digitalWrite(BELL, LOW);
  }
  
  */
  //      digitalWrite(REMOTEINDICATOR, HIGH); 
 // Serial.println(
  // look for a capital D over the serial port and ring the bell if found
  if (Serial.available() > 0) {

val=Serial.read();
    
    if (val == 'D'){
      //ring the bell briefly
      
      Serial.print('K');
      digitalWrite(REMOTEINDICATOR, HIGH);
      delay(10);
      digitalWrite(REMOTEINDICATOR, LOW);
    //  Serial.print("hi");
      // uncomment the next line if you don't have an oscillating buzzer
      //tone(BELL, 440, 100); 
    }

  }
}


No comments:

Post a Comment