Skip to content

Instantly share code, notes, and snippets.

@deepakkarki
Last active August 29, 2015 14:19
Show Gist options
  • Save deepakkarki/5ad77ad68a7f831c63db to your computer and use it in GitHub Desktop.
Save deepakkarki/5ad77ad68a7f831c63db to your computer and use it in GitHub Desktop.
#include <Servo.h>
Servo myservo;
int key_inserted,gear_pedal;
boolean stand_up;
void setup() {
myservo.attach(9);
pinMode(8,INPUT);
pinMode(12,INPUT);
pinMode(7,OUTPUT);
pinMode(13,OUTPUT);
digitalWrite(7,HIGH);
digitalWrite(13,HIGH);
stand_up = false;
}
void loop() {
key_inserted=digitalRead(8);
if(key_inserted == LOW){
//if the key is out, reset stand
myservo.write(0);
stand_up = false;
}
//if the key is inserted, but stand not up
else if(!stand_up){
gear_pedal = digitalRead(12);
if(gear_pedal==HIGH){
myservo.write(106);
//the stand is now up
//it doesn't matter if gear goes up or down now
//untill key is removed
stand_up = true;
}
}
//else stand is up, and you are moving, so do nothing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment