Samson Punter
Published © Beerware

Daddy flag

GPS controlled flag to indicate when daddy is coming home.

Full instructions provided888
Daddy flag

Things used in this project

Hardware components

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

Story

Read more

Code

daddy-flag.ino

C/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

Samson Punter

Samson Punter

2 projects • 1 follower
Samson likes to make things; Lego, wood, electronics and web applications are some of his favourite building blocks.
Contact

Comments