Skip to content

Instantly share code, notes, and snippets.

@xranby
Created October 22, 2015 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xranby/9d40a38ff172493492fa to your computer and use it in GitHub Desktop.
Save xranby/9d40a38ff172493492fa to your computer and use it in GitHub Desktop.
#include <Servo.h>
Servo myServo; // create a servo object
void setup() {
// ställ in utgångar (lamporna)
pinMode(5, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(6, INPUT);
myServo.attach(13); // attaches the servo on pin 9 to the servo object
}
int angle;
void loop() {
// read the state of the pushbutton value:
int blo = digitalRead(7);
int rod = digitalRead(8);
int gron= digitalRead(6);
angle = map(blo, 0, 1, 0, 179);
myServo.write(angle);
if (blo == HIGH) {
// turn LED on:
digitalWrite(4, HIGH);
}
else {
// turn LED off:
digitalWrite(4, LOW);
}
if (gron == HIGH) {
// turn LED on:
digitalWrite(5, HIGH);
}
else {
// turn LED off:
digitalWrite(5, LOW);
}
if (gron == HIGH) {
// turn LED on:
digitalWrite(3, HIGH);
}
else {
// turn LED off:
digitalWrite(3, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment