Things used in this project

Hardware components:
Core
Particle Spark Core
×1
Servo (generic)
Controlled via pins A0 & A1
×2

Code

daddy-flag.inoC/C++
Servo pan;  // create servo object to control a servo
Servo tilt;  // create servo object to control a servo
int panval = 90;
int tiltval = 170;

int flagdown(String args) {
    tiltval = 170;
    panval = 90;
  return 1;
}

int flagup(String args) {
    tiltval = 120;
        pan.write(panval);              // tell servo to go to position in variable 'val'
        tilt.write(tiltval);              // tell servo to go to position in variable 'val'
      for (int rep=0; rep<4; rep++) {  
            for (int i=10; i<170; i++) {
                panval = i;
                pan.write(panval);              // tell servo to go to position in variable 'val'
                tilt.write(tiltval);              // tell servo to go to position in variable 'val'
                delay(15);
            }
            delay(500);
            for (int j=170; j>10; j--) {
                panval = j;
                pan.write(panval);              // tell servo to go to position in variable 'val'
                tilt.write(tiltval);              // tell servo to go to position in variable 'val'
                delay(15);
            }
            delay(50);
      }
      
    panval = 90;
    tiltval = 90;
    pan.write(panval);              // tell servo to go to position in variable 'val'
    delay(50);
    tilt.write(tiltval);              // tell servo to go to position in variable 'val'
    
    
    
    
  return 1;
}



void setup() {
  pan.attach(A0);  // attaches the servo on the A0 pin to the servo object
  tilt.attach(A1);  // attaches the servo on the A1 pin to the servo object
  
   Spark.function("down", flagdown);
   Spark.function("up", flagup);

}

void loop() {
    pan.write(panval);              // tell servo to go to position in variable 'val'

    tilt.write(tiltval);              // tell servo to go to position in variable 'val'

}

Credits

2014 09 16 19.39.11
Samson Punter

Samson likes to make things; Lego, wood, electronics and web applications are some of his favourite building blocks.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Building a WiFi Outlet
  • 69,069
  • 176

Full instructions

I decided to build a wifi-enabled outlet with my Spark Core.

Spark Non-Invasive Smart Electricity Meter
  • 16,387
  • 86

Full instructions

A simple Non-Invasive Smart Electricity Meter using Spark Core

An e-paper, wifi keypad
  • 17,695
  • 77

Full instructions

How Spark Core helped us make a Wi-Fi keylock with e-paper keypad for our office

WeatherMon_SparkCore
  • 5,659
  • 22

Full instructions

Weather Monitoring using Spark Core

LetterBot
  • 21,794
  • 63

Work in progress

Every Home Should Have One.

Spark Core and SmartThings
  • 12,342
  • 51

Full instructions

Application that integrates Spark Core and SmartThings

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog