Introduction: SAFETY BED

Natural disasters such as earthquake , tsunami and fire happening all around the world . Natural disasters happens and may take human life away . Therefore , this project may save your life if a natural disaster happen .

You may be wondering , how can a bed save someone's life ? This bed is no ordinary bed , it has sensors and a cover that will close the bed tightly , bringing you to a chamber filled with supplies such as oxygen , food , water , first aid kit to help you survive for at least a week . The bed can hold strong impact , protecting you safely inside .

First thing first , this bed will not close if you are not on the bed when a natural disaster occur . Can you imagine running to the bed and the bed just closed without you ? Well , I've thought of that ! The bed is installed with sensors which will sense the presence of YOU on the bed before closing .

Secondly , the bed is surrounded with material that can float on water . The bed is also installed with motors which will act as " flippers " which will help balance the bed so you could be safe in the bed .

Now you are wondering , if a fire occurred , will the fire burn the bed up ? The answer is NO , the material used to make this bed is fireproof and heat proof .

Lastly , How do you get out ? Simple ! There is a button installed in the chamber , all you have to do is push the button and the cover will open right up for you to get out .

In this tutorial , you will learn how to make a prototype safety bed !

There is a video of how the bed works , please download to watch !

Step 1: Step 1 : Gather Your Components !

You will need :

2 servo motors

4 dc motors

1 rain / water sensor

1 PIR sensor

1 flame sensor

1 vibration sensor

1 pushbutton

Some 10k resistor

2 L293d

Step 2: Step 2 : Make Your Bed Frame !

1) This bed was frame cut out and glued with hot glue but of course any box will be fine.

2) Then make a lid for the bed frame , make sure it covers the bed perfectly !

3) Make sure the bed frame is deep enough to put your connections , supply box and your bed !

4) Then add some polystyrene or anything that can float and support the whole bed surrounding the bed frame , make sure it doesn't cover the bottom part of the bed frame as there will be a water sensor attached below the bed .

Step 3: Step 3 : Connect the Servo Motors

1)The red wire of the servo should be connected to 5v on the arduino , the brown to GND and the orange to a pin . In this case I connected the orange wire to pin 8.

2)Attach it to the lid of the bed , make sure it able to control the lid to move.

Step 4: Step 4 : Connect Your Dc Motors !

1) Connect the 4 dc motors , 2 motors on each sides .

2) Since this bed needs 4 dc motors , a l293d can be used to connect the motors easier ( optional )

3) So , connect all for edges of the l293d to 5v

4) Then followed by pins . In this case I used pin 11 and pin 12 for all the dc motors

Step 5: Step 5 : Connect the Rain / Water Sensor

1) Connect the rain sensor as shown in the picture . Make sure you connect it to an analog pin . I connected it to A1

2) Attach your rain sensor to the bottom of the bed frame .

3) Cut a hole at the bottom of the bed frame that fits the rain sensor perfectly .

4) Seal the edges of the hole , make sure no water can get in .

Step 6: Step 6 : Connect Your Vibration Sensor

1) Connect one end of the vibration sensor to 5v and the other end to an analog pin . In this case I connected it to A0

2) Attach this sensor below the bed

Step 7: Step 7 : Connect Your Flame Sensor

1) Connect the "VCC" to 5v

2) Connect the "AO" to Analog pin , I used A1

3) Connect the GND

4) Install this sensor onto the bed frame

Step 8: Step 8 : Connect Your PIR Sensor

1) Connect the VCC to 5v

2) Connect the GND

3) Connect the Output to a pin. I had used pin 3 .

4) Attach it in the bed .

Step 9: Step 9 : Connect Your Buttons

1) I had used a two pin pushbutton

2) The connection of this button is simple .

3) Just connect one end of the button to 5v and the other to a resistor and then to a digital pin ( i used Pin 10 ) then to GND .

Step 10: Step 10 : Programming

#include

int pir = 3;

int vibration = A0;

int water = A1;

int flame = A2 ;

const int sensorMin = 0; // sensor minimum

const int sensorMax = 1024;

int dc1 = 11;

int dc2 = 12;

int pushbutton = 10;

int buzzer = 7;

Servo myservo;

void setup() {

myservo.attach ( 8 );

pinMode ( pir , INPUT );

pinMode ( vibration , INPUT );

pinMode ( water , INPUT );

pinMode ( flame , INPUT );

pinMode ( dc1 , OUTPUT );

pinMode ( dc2 , OUTPUT );

pinMode ( pushbutton , INPUT );

pinMode ( buzzer , OUTPUT );

myservo.write ( 170 );

digitalWrite ( dc1 , HIGH );

digitalWrite ( dc2 , LOW );

Serial.begin ( 9600 ); }

void loop() {

int pirvalue = digitalRead ( pir );

int pbval = digitalRead ( pushbutton );

int sensorReading = analogRead(A2);

int waterlevel = analogRead ( water );

int vibrate = analogRead ( vibration );

int firerange = map(sensorReading, sensorMin, sensorMax, 0, 3); //no fire , distance fire , close fire

int waterrange = map ( waterlevel , sensorMin , sensorMax , 0 , 3); //dry , moist , wet int vibraterange = map ( vibrate , sensorMax , sensorMin , 0 , 3);//not vibrating , some shake , not vibrating

Serial.println ( pbval );

switch (firerange) { case 0: // A fire closer than 1.5 feet away. Serial.println("** Close Fire **");

if ( pirvalue == 1 ){ myservo.write ( 0 );//got fire close

digitalWrite ( buzzer , HIGH );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

}else {

noTone ( buzzer );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

}

break;

case 1: // A fire between 1-3 feet away.

Serial.println(" Distant Fire ");

if ( pirvalue == 1 ){ myservo.write ( 0 );//got fire close

digitalWrite ( buzzer , HIGH );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

}else {

noTone ( buzzer );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

}

break;

case 2: // No fire detected.

Serial.println("No Fire");

noTone ( buzzer );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

break;

}

delay ( 100 );

switch ( waterrange ){

case 0 : Serial.println ( "**Water High**" );

if ( pirvalue == 1 ){ myservo.write ( 0 );//got water close

digitalWrite ( buzzer , HIGH );

digitalWrite ( dc1 , HIGH );

digitalWrite ( dc2 , LOW );

}else {

noTone ( buzzer );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

}

break;

case 2 :

Serial.println ( "** Water is not detected **" );

noTone ( buzzer );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

break;

case 3 : Serial.println ( " no water is detected " );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

noTone ( buzzer ) ;

break ;

}

delay ( 100 );

if ( vibrate > 870 ) { Serial.println ( " Detected Eartquake " );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

myservo.write ( 0 );

digitalWrite ( buzzer , HIGH );

}else {

Serial.println ( vibrate) ;

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

noTone ( buzzer );

}

delay ( 100 );

if ( pbval == 1 ) {

myservo.write ( 170 );

delay ( 10000 );

noTone ( buzzer );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

}else {

noTone ( buzzer );

digitalWrite ( dc1 , LOW );

digitalWrite ( dc2 , LOW );

}

}

Epilog Challenge 9

Participated in the
Epilog Challenge 9

First Time Author Contest 2018

Participated in the
First Time Author Contest 2018

Arduino Contest 2017

Participated in the
Arduino Contest 2017