Project showcase
Automatic Baby Rocker!

Automatic Baby Rocker!

Automatic baby rocker to help the baby sleep. Fastened to the stroller with a rope.

  • 2,243 views
  • 1 comment
  • 8 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

About this project

I was tired of cradling the stroller when the baby was crying. So I made an automatic cradle for the stroller. I used a Arduino uno, and an engine from a windscreen wiper. Powered by a 230VAC-12VDC converter.

Code

BabyRocker.inoC#
Here is the baby rocker that i made.
/*
Baby Rocker
Developer: Sindre Krgsrud, February 2017.

*Start:
  - The rocker will run continuously until you push "STOP".

*Auto
  - The rocker will run for (x)milliseconds everytime a sound is detected.

*Timer
  - When you push "Timer" the rocker will run (0-5000)millisecond depending on what the "TimerWheel" is set to. 
                                              ( TEST )
*/

// Global Variables and boolean's

unsigned long previousMillis = 0; 
long interval = 3000; 

const int timerWheel = A0;
const int SoundSensor = A5;
const int LED = 3;
const int stopButton = 4;
const int startButton = 5;
const int autoButton = 6;
const int timerButton = 7;
const int stopLED = 8;
const int startLED = 9;
const int autoLED = 10;
const int timerLED = 11;
const int timerLED1 = 12;
const int timerLED2 = 13;
const int timerLED3 = A1;
const int timerLED4 = A2;
const int timerLED5 = A3;
const int timerLED6 = A4;

boolean stopButtonPushed = true;
boolean startButtonPushed = false;
boolean autoButtonPushed = false;
boolean timerButtonPushed = false;
boolean stopButtonSignal = false;
boolean startButtonSignal = false;
boolean autoButtonSignal = false;
boolean timerButtonSignal = false;

boolean autoStart = false;
boolean timerStart = false;

unsigned long timerWheelTime = 0;
int timerWheelVal = 0;
int SoundSensorVal = 0;
boolean SoundDetected = false;
boolean setMillis = true;


void setup() {

pinMode(timerWheel, INPUT);
pinMode(SoundSensor, INPUT);
pinMode(stopButton, INPUT);
pinMode(startButton, INPUT);
pinMode(autoButton, INPUT);
pinMode(timerButton, INPUT);

pinMode(LED, OUTPUT);
pinMode(stopLED, OUTPUT);
pinMode(startLED, OUTPUT);
pinMode(autoLED, OUTPUT);
pinMode(timerLED, OUTPUT);
pinMode(timerLED1, OUTPUT);
pinMode(timerLED2, OUTPUT);
pinMode(timerLED3, OUTPUT);
pinMode(timerLED4, OUTPUT);
pinMode(timerLED5, OUTPUT);
pinMode(timerLED6, OUTPUT);

digitalWrite(LED, LOW);

}

void loop() 
{
  
unsigned long currentMillis = millis();

//timerWheel
if ( true == true )
{
  

timerWheelVal = analogRead(timerWheel);
// 30s,1m,2m,4m,8m,16m
/*

*/
// TEST
timerWheelTime = map (timerWheelVal, 0, 1023, 500, 16000);


 if ( timerWheelTime >= 500 && timerWheelTime < 1000 )
 {
  digitalWrite(timerLED1, HIGH);
 }
 else
 {
  digitalWrite(timerLED1, LOW);
 }
 
 if ( timerWheelTime >= 1000 && timerWheelTime < 2000 )
 {
  digitalWrite(timerLED2, HIGH);
 }
 else
 {
  digitalWrite(timerLED2, LOW);
 }
  
 if ( timerWheelTime >= 2000 && timerWheelTime < 4000  )
 {
  digitalWrite(timerLED3, HIGH);
 }
 else
 {
  digitalWrite(timerLED3, LOW);
 }

 if ( timerWheelTime >= 4000 && timerWheelTime < 8000 )
 {
  digitalWrite(timerLED4, HIGH);
 }
 else
 {
  digitalWrite(timerLED4, LOW);
 }

 if ( timerWheelTime >= 8000 && timerWheelTime < 15500)
 {
  digitalWrite(timerLED5, HIGH);
 }
 else
 {
  digitalWrite(timerLED5, LOW);
 }

 if ( timerWheelTime >= 15500)
 {
  digitalWrite(timerLED6, HIGH);
 }
 else
 {
  digitalWrite(timerLED6, LOW);
 }

}

//Button and LED states 
if ( true == true )
{
int stopButtonState = digitalRead(stopButton);
 if (stopButtonState == HIGH )
  {
   stopButtonPushed = true;
   stopButtonSignal = true;
  }
digitalWrite(stopLED,stopButtonPushed);   

int startButtonState = digitalRead(startButton);
 if (startButtonState == HIGH )
  {
   startButtonPushed = true;
   startButtonSignal = true;
  }
digitalWrite(startLED,startButtonPushed);  

int autoButtonState = digitalRead(autoButton);
 if (autoButtonState == HIGH )
  {
   autoButtonPushed = true;
   autoButtonSignal = true;
  }
digitalWrite(autoLED,autoButtonPushed);  

int timerButtonState = digitalRead(timerButton);
 if (timerButtonState == HIGH )
  {
   timerButtonPushed = true;
   timerButtonSignal = true;
  }
digitalWrite(timerLED,timerButtonPushed);  
}

 //STOPP
 if ( stopButtonSignal == true )
  {
   stopButtonSignal = false;
   startButtonPushed = false;
   autoButtonPushed = false;
   timerButtonPushed = false;
   timerButtonSignal = false;
   autoStart = false;
   timerStart = false;
   digitalWrite(LED, LOW);
  }

 //START
 if ( startButtonSignal == true )
  {
   startButtonSignal = false;
   stopButtonPushed = false;
   autoButtonPushed = false;
   timerButtonPushed = false;
   autoStart = false;
   timerStart = false;
   digitalWrite(LED, HIGH); 
  }

 //AUTO
 if ( autoButtonSignal == true )
  {
   autoButtonSignal = false;
   stopButtonPushed = false;
   startButtonPushed = false;
   timerButtonPushed = false;
   timerStart = false;
   digitalWrite(LED, LOW);
   autoStart = true;
  }
 
 // AUTOSTART
 if ( autoStart == true )
  {
   if ( (SoundSensorVal = digitalRead(SoundSensor)) == 1 )
    {
     SoundDetected = true;
     setMillis = true;
    }
   if ( SoundDetected == true )
    {
     if(setMillis == true)
      {
       setMillis = false;
       previousMillis = currentMillis;
      }
     if (currentMillis - previousMillis <= timerWheelTime/2 ) 
      {
       digitalWrite(LED, HIGH);
      }
     else
      {
       digitalWrite(LED, LOW);
       setMillis = true;
       SoundDetected = false;
      }
    }   
  }


 //TIMER
 if ( timerButtonSignal == true )
  {
   timerButtonSignal = false;
   stopButtonPushed = false;
   startButtonPushed = false;
   autoButtonPushed = false;
   autoStart = false;
   digitalWrite(LED, LOW); 
   timerStart = true;
  }
 
 //TIMERSTART
 if ( timerStart == true )
  {
   if(setMillis == true)
    {
     setMillis = false;
     previousMillis = currentMillis;
    }
   if (currentMillis - previousMillis <= timerWheelTime) 
    {
     digitalWrite(LED, HIGH);
    }
    else
    {
     digitalWrite(LED, LOW);
     stopButtonSignal = true;
     stopButtonPushed = true;
     setMillis = true;
    }
  }












  

}

Comments

Similar projects you might like

Advance Automatic Railway Crossing System

Project showcase by Pawan singh and Akansh Saxena

  • 6,144 views
  • 2 comments
  • 18 respects

Automatic Gate with FSM and ISR

Project showcase by AndreNeves and Nuno Miguel Guerreiro Carvalho Martins

  • 1,808 views
  • 0 comments
  • 2 respects

Dual Axis Solar Tracker Panel with Auto and Manual Mode

Project tutorial by Giannis Arvanitakis

  • 21,846 views
  • 12 comments
  • 70 respects

Cool Baby Piano

Project showcase by cool guys

  • 1,376 views
  • 0 comments
  • 1 respect

Fairytale

Project in progress by siliconchris

  • 1,281 views
  • 3 comments
  • 3 respects

Smart Garden

Project showcase by patel Dipen

  • 40,960 views
  • 18 comments
  • 89 respects
Add projectSign up / Login