Can you post all your code and your schematic?
all code, a lot of it doesnt have anything to do with my problem, but here you are:
int TempPin = A0;
int HeadPin = A1;
int BodyPin = A2;
int TailPin = A3;
int ResHiPin = A4;
int ResLoPin = A5;
int RelayPin = 8;
int PumpPin = 9;
int ServoPin = 10;
int SpkrPin = 11;
int SolPin = 12;
int ButtonPin = 7;
int CurrentPos = 0; //set servo current pos
int pos = 0; //temp storage of pos for fluid movment
int ResLo = 0;
int ResHi = 0;
int WaterState = 0; //state 0 = Off, State 1 = On.
int Temp = 0; // store of temperature
int ButtonState = 0; // variable for reading the pushbutton status
#include <Servo.h>
Servo flowservo; // create servo object to control a servo
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode( RelayPin, OUTPUT);
pinMode( PumpPin, OUTPUT);
pinMode( ServoPin, OUTPUT);
pinMode( SpkrPin, OUTPUT);
pinMode( SolPin, OUTPUT);
pinMode( ButtonPin, INPUT);
flowservo.attach(ServoPin);
}
void loop() {
//startup pause
while (ButtonState == 0) {
ButtonState = digitalRead(ButtonPin); // read the state of the pushbutton value:
Serial.println("waiting for button press");
}
for(int a = 0; a < 100; a++){
Pump(a);
delay(200);
}
for(int a = 100; a > 0; a--){
Pump(a);
delay(200);
}
//GetTemp();
//ServoGoto(10);
delay (2000);
//beep(200, 2); // beep(ms, repeats) ms= time to beep for, repeats = number of times to beep.
//beep(400, 3);
//Checks water resivoir level and turns on tap if needed.
ResLo = analogRead(ResLoPin);
Serial.print ("lo: ");
Serial.println(ResLo);
if (ResLo < 400) {
WaterOn();
if(ResHi = analogRead(ResHiPin) > 400){
beep(200, 5);
}
}
if (WaterState == 1){
ResHi = analogRead(ResHiPin);
Serial.print ("hi: ");
Serial.println(ResHi);
if (ResHi > 400) {
WaterOff();
}
}
} // end void loop -----------------------------------------------
// pump control -----------------------------------------------------
void Pump(int percent){
int pumpval = map (percent, 0, 100, 0, 255);
analogWrite(PumpPin, pumpval);
Serial.print ("pumpval: ");
Serial.println(pumpval);
}
// Water control ------------------------------------------------------
void WaterOn(){
digitalWrite(SolPin, HIGH);
WaterState = 1;
}
void WaterOff(){
digitalWrite(SolPin, LOW);
WaterState = 0;
}
// Power for Element control subroutine -------------------------------------------
void PowerOn(){
digitalWrite(RelayPin, HIGH);
}
void PowerOff(){
digitalWrite(RelayPin, LOW);
}
// Setup Beeper ----------------------------------------------------------------------
void beep(unsigned char delayms, int repeats){
// Random frequency between 20 and 1400 (Hz).
for(int i=0; i < repeats; i ++){
unsigned long freq = (1400);
tone(SpkrPin, freq, delayms);
delay (delayms);
freq = (1000);
tone(SpkrPin, freq, delayms);
delay(delayms);
}
}
// Servo control subroutine-----------------------------------------------------------
void ServoGoto(int gotopos){
Serial.print("currentpos: ");
Serial.println(CurrentPos);
Serial.print("pos: ");
Serial.println(pos);
Serial.print("gotopos: ");
Serial.println(gotopos);
Serial.println();
if (CurrentPos < gotopos){
for(pos = CurrentPos; pos < gotopos; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
flowservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
CurrentPos = pos;
}
if (CurrentPos > gotopos){
for(pos = CurrentPos; pos > gotopos; pos-=1) // goes from 180 degrees to 0 degrees
{
flowservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
CurrentPos = pos;
}
}
// read temp subroutine ------------------------------------------------------------------
void GetTemp() {
// read the analog in value:
int sensorValue = analogRead(TempPin);
// map it to the range of the analog out:
Temp = map(sensorValue, 20, 210, 25, 100);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(Temp);
}
as for schematic... i dont really have one. so ive draw it (quiet crudely) here: