Remote Servo


hi,

i'm new arduino, , first post.  may basic question guys.

i have simple rf receiver single button key fob (http://www.adafruit.com/product/1096)

when press button, want turn servo 90 degrees, wait couple seconds turn back. 

can me code , schematics?

thank much.

code: [select]
// when press button...
const int buttonpin = 2;

// want turn servo...
const int lockservopin = 3;
#include <servo.h>
servo lockservo;

void setup() {
  // when press button...
  pinmode(buttonpin, input);

  // want turn servo...
  lockservo.write(0);
  lockservo.attach(lockservopin);
}

void loop() {
  // when press button...
  if (digitalread(buttonpin)) {
    // ... want turn servo 90 degrees...
    lockservo.write(90);
    // ...wait couple seconds...
    delay(2000);
    // ...then turn back. 
    lockservo.write(0);
  }
}


Arduino Forum > Using Arduino > Project Guidance > Remote Servo


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code