Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
SOURADIPTA MOHANTY
Created October 30, 2016

Who woke me up!! A Halloween contest Submission

A mobile on a harmless holder suddenly wakes up, starts walking and says "who woke me up" . Used Arduino, 1Sheeld and Tasker.

68
Who woke me up!! A Halloween contest Submission

Things used in this project

Story

Read more

Code

Arduino Code Used for the peoject

C/C++
Checks input pin value and starts two servos
#include <Servo.h>

#include <OneSheeld.h>

Servo myservo1;
Servo myservo2;


//define triggers and buttons for movement
long button1;
int pos = 0;
int pos1 = 0;

int i = 0;

void setup()
{
  //myservo1.attach(9);
//  myservo2.attach(10);
  pinMode(11, INPUT);
  digitalWrite(11, LOW);

}

void loop()
{
//start dancing!!
button1 = digitalRead(11);
  if (button1 == HIGH)
  {
    myservo1.attach(9);
    myservo2.attach(10);
    for (pos = 0; pos <= 90; pos += 10) 
      { 
       myservo1.write(pos);              
       delay(15);                       
      }
    for (pos = 90; pos <= 180; pos += 5) 
      { 
       myservo1.write(pos);              
       delay(15);                       
      }
    for (pos1 = 0; pos1 <= 90; pos1 += 10) 
      { 
       myservo2.write(pos1);              
      delay(15);                       
      }
    for (pos1 = 90; pos1 <= 180; pos1 += 5) 
      { 
       myservo2.write(pos1);              
      delay(15);                       
      }
  
    delay(500);
    for (pos = 180; pos >= 0; pos -= 10) 
      { 
      myservo1.write(pos);              
      delay(15);                       
      }
    for (pos1 = 180; pos1 >= 0; pos1 -= 10) { 
      myservo2.write(pos1);              
      delay(15);                       
      }
      delay(1500);
    myservo1.detach();
    myservo2.detach();
    delay(1000);
}
}

Credits

SOURADIPTA MOHANTY

SOURADIPTA MOHANTY

2 projects • 0 followers
Banking functional consultant!! Learning IOT through Arduino....:-) enjoying it

Comments