Thanks PaulS for your input so far, you do contribute very valueble information, and you definitely know alot about coding and hardware.
I realy do appreciate it.
Please note that I have now created 3 more buttuns for a second servo, but they are not coded in yet to do anything, so ignore buttons 4 through 6 in the C++ Code.
Revised Scetch:
/*
* Serial Read Servo
* -----------------
* Moves a Servo connected to digital pin 9.
* The Servo will move the number given by a
* ASCII number read from the serial port.
* One Servo with two buttons (Pan Left & Pan Right)
* Created 10 March 2011
*/
int Servo1 = 9; // select the pin for Servo1
int val = 0; // variable to store the data from the serial port
void setup() {
pinMode(Servo1,OUTPUT); // declare Servo1 pin as output
Serial.begin(9600); // connect to the serial port
}
void loop () {
val = Serial.read(); // read the serial port
if (val > '1' && val <= '180' ) //Button1 Pan Left represented by a '1'
if (val > '2' && val <= '180' ) //Button2 Pan Right represented by a '2'
if (val > '3' && val == '90' ) //Button3 Center represented by a '3'
val = val - '1'; //Read Value from Button1 converted from character to number
val = val - '2'; //Read Value from Button2 converted from character to number
val = val - '3'; //Read Value from Button3 converted from character to number
for(int i=1; i<val; i++) //Button1 Pan Left
for(int i=2; i<val; i++) //button2 Pan Right
for(int i=3; i<val; i++) //button3 Center
Serial.println("MOVE!"); //message to display in Serial Monitor
digitalWrite(Servo1,val); //Write Value to Servo1
delay(15); //Delay for Servo1
Serial.flush(); //Flush Serial Data, to prevent intermittent movement of servo
return;
}