How about this? i got some help to remove the loop()s
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0;
int val;
// set pin numbers:
const int buttonPin = 10; // the number of the pushbutton pin
const int buttonPin2 = 8;
const int buttonPin3 = 4;
const int buttonPin4 = 2;
void setup()
{
myservo.attach(12); // attaches the servo on pin 12 to the servo object
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
}
void loop()
{
val = analogRead(potpin); //takes reading from pot current position
val = map(val, 0, 1083, 0, 180); //maps pot inputs to servo outputmyservo.write(val); //writes current position to servo to move it
myservo.write(val); //writes current position to servo to move it
if (digitalRead(buttonPin) == HIGH)
serloop1(); //sends command to SerLoop1
if (digitalRead(buttonPin2) == HIGH)
serloop1(); //sends command to SerLoop1
}
void serloop1()
{
int val1 = myservo.read(); //reads current servo location
if (digitalRead(buttonPin) == HIGH)
{
myservo.write(val1 + 2); //SUBTRACT 2 degrees to servo position for increased motor rpm
delay(100); //allows time for switch ro reset
}
if (digitalRead(buttonPin2) == HIGH)
{
myservo.write(val1 - 2); //ADDS 2 degrees to servo position for decreased motor rpm
delay(100); //allows time for switch ro reset
}
if (digitalRead(buttonPin3) == HIGH)
{
//Nothing, just exit
}
if (digitalRead(buttonPin4) == HIGH)
{
//Nothing, just exit
}
else
{
serloop1(); //returns to SerLoop1 to run again
}
}