AUTOMATIC CRADLE

Photo of author

By Jackson Taylor

Home » DIY Tech Projects Hardware » AUTOMATIC CRADLE

As an Amazon Associate we earn from qualifying purchases.

An automatic cradle rocks a baby without a parent having to stand next to it. The version described here is sound-activated: a microphone listens for noise, and when it hears the baby cry, a small microcontroller switches on a relay that powers the rocking motor. When the room goes quiet again, the motor stops.

The video below shows the project working. The rest of this article explains how the circuit is organised, what the program does line by line, and what to think about before you build one.

How the automatic cradle works

The design is simple, and that is its main advantage. It has three working parts:

Hardware Hack

Stop Buying New Batteries for Your Tech

Electronics are expensive, but their power sources don't have to be. Discover the simple engineering trick to recondition dead batteries and bring your gadgets back to 100% capacity.

Watch the Free Video
  • Sound input: a microphone circuit that produces a digital high signal when it picks up enough noise, and a low signal when the room is quiet.
  • Controller: a PIC12F508, a small 8-pin microcontroller, which reads the microphone signal and decides when to act.
  • Output: a relay that switches the motor or mechanism that rocks the cradle.

The microcontroller never drives the motor directly. A relay isolates the low-power control side from the motor side, so the chip is protected from the motor’s current draw and electrical noise.

Microcontroller: PIC12F508

The PIC12F508 is a good fit for a job like this. It has only a few input/output pins, which is all this project needs, and it can run from its internal oscillator, so no external crystal is required. The program sets the clock to 4 MHz for the delay routines.

Two pins do the work:

  • GP5 is the microphone input.
  • GP1 is the relay output.

Because the chip has so few pins, the circuit stays small. It is the same kind of compact build you see in another PIC12F508 project on this site.

Program


//GP5=MIC
//GP1=RELAY
#include<pic.h>
OSSCAL=0X80;
__CONFIG(0X0FEA);
#define _XTAL_FREQ 4000000
void main()
{
TRISGPIO=0X20;GPIO=0;
OPTION= 0XC0;
GP1=1;
__delay_ms(2000);
GP1=0;
while(1)
{
while(GP5==1)
{
GP1=1;
__delay_ms(2000);
}
GP1=0;
}
}

What the code does

  1. Pin setup. TRISGPIO=0X20 makes GP5 an input and every other pin an output. GPIO=0 starts with all outputs low, so the relay is off.
  2. Option register. OPTION=0XC0 turns off the wake-on-change and weak pull-up features, so the pins behave as plain inputs and outputs.
  3. Power-on test. The relay switches on for two seconds and then off. This is a handy check that the relay and motor are wired correctly each time you power up.
  4. Main loop. The program keeps checking GP5. While the microphone signal is high, it holds the relay on and waits two seconds before checking again. When the signal is low, it switches the relay off.
See also
POWER LINE COMMUNICATION BASED ENERGY BILLING AND HOME AUTOMATION

In practice, the cradle rocks in two-second steps for as long as the baby keeps making noise, and it stops soon after the noise ends.

Building the circuit

The program expects a clean digital level on GP5. A bare microphone gives only a tiny analog signal, so the microphone stage needs amplification and a way to turn that signal into a clear high or low. A transistor stage or a comparator is a common way to do this. Check the datasheet for the PIC12F508 and for your relay before you wire anything, and use the voltage and current ratings of your own parts.

Some general points that help:

  • Put a flyback diode across the relay coil. It protects the driver transistor from voltage spikes.
  • Drive the relay coil through a transistor, because a microcontroller pin cannot supply enough current for it.
  • Add a decoupling capacitor close to the chip’s power pins.
  • Keep the microphone wiring away from the motor wiring, since motor noise can cause false triggers.
  • Use a relay and motor suited to the weight of the cradle and the gentle motion you want.

Sensitivity and tuning

Most of the tuning happens in the microphone stage, not in the code. A potentiometer in the amplifier or comparator lets you set how loud a sound must be before GP5 goes high. Set it too sensitive and a door closing or a passing car may start the cradle. Set it too low and a quiet whimper is missed.

The two-second delay in the code is easy to change. A longer delay gives longer, steadier rocking after each trigger. A shorter delay makes the cradle react to the end of the noise more quickly. If the relay clicks on and off rapidly when the microphone signal flickers, adding a short hold-on delay after the sound stops is a simple fix.

Safety notes

This is a hobby electronics project, so treat it with care, particularly because it is meant to be used around a baby.

Sustainable Tech

Keep Toxic E-Waste Out of Landfills

Don't throw away your failing laptop, phone, or car batteries. Learn how to recondition them at home in just a few hours. It's better for the planet—and your wallet.

Learn How It Works
  • Keep all wiring, the relay and the electronics fully enclosed and out of a child’s reach.
  • Use a low-voltage supply for the motor and control circuit, and avoid exposed mains connections near the cradle.
  • Keep the rocking motion slow and gentle, with no pinch points or exposed moving parts.
  • Test the cradle thoroughly with no baby in it before any real use.
  • It does not replace adult supervision. Follow current safe-sleep guidance from your pediatrician or health authority.
See also
LED PROPELLER DISPLAY

Ideas for improving the project

  • Add an indicator LED so you can see when the microphone has triggered.
  • Add a manual switch to turn the automatic mode off.
  • Add a timeout so the cradle stops after a set period even if there is still noise.
  • Use a small gear motor with a crank for smoother, quieter rocking.

If you enjoy this kind of sensor-triggered build, you may also like an automatic turn-off system for an iron box, an automatic chaser circuit with speed control, or an automatic railway gate project. They all use the same idea of sensing an input and switching an output automatically.

Frequently asked questions

What is an automatic cradle?

It is a cradle with a motor and control circuit that rocks it without anyone pushing it. In this project, a microphone triggers the rocking when it hears a baby cry.

Why use a PIC12F508 for this project?

The job needs only one input and one output, and this 8-pin chip can run from its internal oscillator. That keeps the circuit small, cheap and easy to program.

Why does the program switch the relay on at startup?

The relay turns on for two seconds when the circuit powers up and then turns off. It works as a quick self-test, showing you that the relay and motor respond before the cradle is used.

Can I change how long the cradle rocks?

Yes. Change the value in the __delay_ms(2000) line inside the main loop. The number is in milliseconds, so 2000 means two seconds per rocking step.

Revive Your Dead Electronics

Got a drawer full of dead gadgets or a failing car battery? Instead of paying a premium for replacements, use this simple trick to easily recondition them right from home.

See How It Works