Home » Articles » Сорс код

Useless Machine Code

#include <Servo.h>

Servo myservo;
const int button = 2;
int buttonState = 0;
int pos = 0;
void setup() {
  // put your setup code here, to run once:
myservo.attach(9);
pinMode(button, INPUT);
myservo.write(0);
}

void loop() {
  buttonState = digitalRead(button);
  if(buttonState == LOW && pos < 125){
    pos++;
  }
  if(buttonState == HIGH && pos > 0){
    pos--;
  }
  myservo.write(pos);
  delay(2);

}

Category: Сорс код | Added by: MilenTsolov (2016-03-12)
Views: 245 | Rating: 0.0/0
Total comments: 0
avatar