Created
February 5, 2018 22:34
-
-
Save TheVisualG/c21c8702094cb524c094112eec0dd09d 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 servoY; // create servo object to control a servo | |
Servo servoX; | |
int ValX; | |
int ValY; | |
byte Processing; | |
int val; // variable to read the value from the analog pin | |
void setup() { | |
ValY = 0; | |
ValX = 0; | |
Serial.begin(9600); | |
servoX.attach(13); // attaches the servo on pin 9 to the servo object | |
servoY.attach(12); | |
} | |
void loop() { | |
if (Serial.available() > 0) { | |
Processing = Serial.read(); | |
} | |
if (Processing == 'a') { | |
ValY--; | |
servoY.write(ValY); | |
} | |
if (Processing == 'b') { | |
ValY++; | |
servoY.write(ValY); | |
} | |
if (Processing == 'c') { | |
ValX--; | |
servoX.write(ValX); | |
} | |
if (Processing == 'd') { | |
ValX++; | |
servoX.write(ValX); | |
} | |
if (Processing == 'e') { | |
} | |
if (ValX >= 210){ | |
ValX = 210; | |
} | |
if (ValX <= 0){ | |
ValX = 0; | |
} | |
if (ValY >= 210){ | |
ValY = 210; | |
} | |
if (ValY <= 0){ | |
ValY = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment