Sooyeon Jeong

Final Project

My final project is a robot toy figure and its smart bed set that allows me to play a pretend play with my 5 year-old son Jayden. I would like to use it to convince him to turn off the light and go to bed using this toy set. In the play scenario, the robot figure will need to go to sleep when it is 9:30PM. However, the robot would does not want to turn off the light and keep playing. Then, the smart bed sounds the alarm when the room is too bright and does not turn off the annoying sound until it becomes dark enough for sleeping. There are many commercial character-themed kid bed frame and headboard. Here is one example of a kid bed that looks like a fire truck:

Also, my former UROP advisor and an alum from Personal Robots Group, Natalie Freed, made a bed frame that looks like a ship in How to Make class in a previous year: http://www.nataliefreed.com/projects/how-to-make-almost-anything/bed2/ I designed the bed frame cuts and the board diagram for the PCB with Antimony. I designed 2D shapes to layout shapes for press-fit and exported the model into .png file using the height map export feature. I used the cardboard provided for the class and cut it with the Epilog laser cutting machine in the CBA shop. The press fit slots were a bit loose so I glued the connecting parts for ensuring the structure.

I designed the PCB to sense the light intensity through a phototransistor, receive users' input through a press button and output audio through a speaker with Eagle. The button was to be used to notify the system that the interaction has started and to signal that it is “time to sleep.”I used the one sided copper board, a speaker from Personal Robots Group, a NPN Phototransistor Opaque, a press button, ATTiny45 microprocessor, a 5V regulator, a N-MOSFET, 4 resistors, a capacitor, a FTDI-USB connector, 2x3 and 2x2 male SMD pin connectors, a 2x2 female SMD pin connector and two pieces of short wires.

I programmed the stuffed board with Arduino and AVR mkII programmer. The source code looks as below:

#include <SoftwareSerial.h>

#include <avr/io.h>
#include <util/delay.h>

#define output(directions,pin) (directions |= pin) // set port direction for output
#define set(port,pin) (port |= pin) // set port pin
#define clear(port,pin) (port &= (~pin)) // clear port pin
#define pin_test(pins,pin) (pins & pin) // test for port pin
#define bit_test(byte,bit) (byte & (1 << bit)) // test for bit set

#define cycle_delay() _delay_us(2) // cycle delay
#define current 150 // PWM current
#define off 255 // PWM off

#define MOSFET_pin (1 << PB1)
#define MOSFET_port PORTB
#define MOSFET_direction DDRB

SoftwareSerial serial(0,2);

int sensorPin = 3; // select the input pin for the phototransistor
int buttonPin = 4; // select the input pin for the button

int sensorValue = 0; // variable to store the value coming from the sensor
int buttonState = LOW;

static unsigned short cycle, cycles, lfsr, delayLength, curBit;


void setup() {

 pinMode(sensorPin, INPUT);
 pinMode(buttonPin, INPUT_PULLUP);
 
 CLKPR = (1 << CLKPCE); CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);

 TCCR0A = ((1 << COM0B0) | (1 << COM0B1) | (1 << WGM01) | (1 << WGM00)); 
 TCCR0B = (1 << CS00); // set timer 0 prescalar to 1

 clear(MOSFET_port, MOSFET_pin);
 output(MOSFET_direction, MOSFET_pin);
 
 lfsr = 1;

 serial.begin(9600);
}

void loop() {
 sensorValue = analogRead(sensorPin);
 buttonState = digitalRead(buttonPin);
 serial.println(sensorValue);
 serial.println(buttonState);
 
 if (sensorValue <= 1000 && buttonState == LOW) {
 playAudioClip();
 }

 delay(100);
}

void playAudioClip() {
 int i = 0;
 for (i = 0; i < 14; i++) {
 curBit = ((lfsr >> 0) ^ (lfsr >> 9)) & 1;
 lfsr = (lfsr >> 1) | (curBit << 10);
 
 // loop over cycles
 cycles = (1 << 15) / lfsr;
 serial.println(cycles);
 for (cycle = 0; cycle < cycles; ++cycle) {
 // set PWM current on and delay
 OCR0B = current;
 for (delayLength = 0; delayLength < lfsr; ++delayLength) {
 cycle_delay();
 }
 
 // set PWM current off and delay
 OCR0B = off;
 for (delayLength = 0; delayLength < lfsr; ++delayLength)
 cycle_delay();
 }
 } 
}

The robot doll design was taken from a website called Cubify. It's a website where people upload 3D printable STL files for various gadgets including robot figures. I tried to 3D print it with the Ultimaker Replicator in Object Based Media Group. However, the extruder got clogged so instead I asked Tom to print it with the 3D printer in the CBA shop. The parts were printed in StrataSys Eden260VS machine with the support material. Tom taught me how to use the high water pressure to remove the support material. I was told to always leave the door open when the machine is not used. Otherwise, the mold will start to grow inside and I'd be called to remove the mold.. I pressed the pedal to start the water to come out and the cleaned all the parts. After the cleaning process, I assembled it and it became a robot figure!


I glued the PCB and the speaker on the headboard. Since it was a “smart” bed, I wanted it to look more tech-y with the visible circuit. Then I cut a piece of fabric that was in the Personal Robots Group and glued it on the frame and placed the robot figure on top of the fabric. I also put a snow bear cast I made for the mold and cast assignment.

I did not spend any personal money on the project. All the components used in the project were provided for the class, except for the speaker I got from the Personal Robots Group. The speaker was from DigitKey and costs ~$2.5 if purchasing only one at a time. Other parts are also not so expensive. ATTiny45 costs $1.48 if purchased one stock at a time but who would ever do that..?

The system was evaluated by pressing the button when the office light on and off. When the light is on, the speaker would output random tones for a few seconds upon a press input on the button. When the light is off, the speaker would not make any noise upon a press input on the button. Here's the link to the video.

My original project proposal was to make a twin size bed frame and a headboard with a robotic agent attached. However, I had limited time at the end of the semester and had to scale down the scope of the project. Instead, I made a mock-up bed with a little bit of sensing and output features, and it was satisfying to realize that I now felt a lot more comfortable with (1) designing 2D/3D objects with Antimony, (2) creating a schematic and board layout with Eagle, (3) laser cutting with Epilog machine, (4) milling the PCB with Roland machine, (5) soldering and debugging a circuit board and (6) 3D printing processes.

The implications for this project is that the smart bed can become even smarter with more sensors are incorporated into the system. Perhaps, I could install an accelerometer on the mattress in the next iteration to measure the movement. If the accelerometer can detect that the user is making more physical movements than just tossing around and is clearly jumping and goofing off, the smart bed can remind the user to go to sleep. Or the speaker could go inside the robot toy figure instead and the robot character could notify the user that it is time for bed.