Need a serial read out put for testing added to the code below I try and never seem to get it right. What I'm trying to do is print the temp sensed and if relays are high or low
/*
Controller For outdoor air control (Factor Default 4 fan)
Arudino Duemilanove port connections:
Digital Inputs
Push button TB2 at port
Push button TEST at port
Analog Input
temperature sensors;
TempSens1 at port
Outputs
relay1 at port
relay2 at port
relay3 at port
*/
// Pin Assignments:
const int TempSens1 = 2; // pin to which temperature sensor 1 is attached to
//const int TB2 = 2; // pin to which TB2 button is conencted
//const int TEST = 3; // pin to which TEST button is conencted
const int Relay1 = 12; //pin to which relay 1 is conencted
const int Relay2 =11; //pin to which relay 2 is conencted
const int Relay3 = 10; //pin to which relay 3 is conencted
const unsigned char temp1=1; //.5 degree*10mV*1024/5V
const unsigned char temp2=47; //23 degree*10mV*1024/5V
const unsigned char temp3=59; //29 degree*10mV*1024/5V
float temperature = 0; //added for serial read
// Variables:
int TempSens1_Reading= 0; // temperature sensor 1 reading
//int TB2buttonState; // the current reading from the input pin
//int TB2lastButtonState = LOW; // the previous reading from the input pin
//long TB2lastDebounceTime = 0; // the last time the output pin was toggled
//int TESTbuttonState; // the current reading from the input pin
//int TESTlastButtonState = LOW; // the previous reading from the input pin
//long TESTlastDebounceTime = 0; // the last time the output pin was toggled
//long debounceDelay = 150; // the debounce time; increase if the output flickers
//int read_TB2(){
//int reading = digitalRead(TB2);
//if (reading != TB2lastButtonState) {
//TB2lastDebounceTime = millis();
//}
//if ((millis() - TB2lastDebounceTime) > debounceDelay) {
//TB2buttonState = reading;
//}
//TB2lastButtonState = reading;
//return TB2buttonState;
//}
//int read_TEST(){
//int reading = digitalRead(TEST);
//if (reading != TESTlastButtonState) {
//TESTlastDebounceTime = millis();
//}
//if ((millis() - TESTlastDebounceTime) > debounceDelay) {
//TESTbuttonState = reading;
//}
//TESTlastButtonState = reading;
//return TESTbuttonState;
//}
void setup() {
// Assign inputs and outputs
//pinMode(TB2 , INPUT); //set TB2 pin an input pin
//pinMode(TEST , INPUT); //set TEST pin an input pin
pinMode(Relay1, OUTPUT); //set Relay1 pin an ouput pin
pinMode(Relay2, OUTPUT); //set Relay1 pin an ouput pin
pinMode(Relay3, OUTPUT); //set Relay1 pin an ouput pin
digitalWrite(Relay1, LOW);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, LOW);
}
void loop() {
//while (read_TEST()==true){
//digitalWrite(Relay1, HIGH);
//digitalWrite(Relay2, HIGH);
//digitalWrite(Relay3, HIGH);
//}
//while (read_TEST()==false && read_TB2()==false){
//digitalWrite(Relay1, LOW);
//digitalWrite(Relay2, LOW);
//digitalWrite(Relay3, LOW);
// }
//while (read_TEST()==false && read_TB2()==true){
TempSens1_Reading = analogRead(TempSens1);
if (TempSens1_Reading >=temp1){
digitalWrite(Relay1, LOW);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, HIGH);
}
if (TempSens1_Reading >=temp2){
digitalWrite(Relay1, HIGH);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, HIGH);
}
if (TempSens1_Reading >=temp3){
digitalWrite(Relay1, HIGH);
digitalWrite(Relay2, HIGH);
digitalWrite(Relay3, HIGH);
}
if (TempSens1_Reading <=temp3){
digitalWrite(Relay1, HIGH);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, HIGH);
}
if (TempSens1_Reading <=temp2){
digitalWrite(Relay1, LOW);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, HIGH);
}
if (TempSens1_Reading <=temp1){
digitalWrite(Relay1, LOW);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, LOW);
}
}
//}