Skip to content

Instantly share code, notes, and snippets.

@TheVisualG
Created February 5, 2018 22:34
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 TheVisualG/c21c8702094cb524c094112eec0dd09d to your computer and use it in GitHub Desktop.
Save TheVisualG/c21c8702094cb524c094112eec0dd09d to your computer and use it in GitHub Desktop.
#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