Created
October 22, 2015 15:32
-
-
Save xranby/9d40a38ff172493492fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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