Hello all, First off, i am a noob when it comes to the arduino platform, i ordered a Arduino UNO and i will be recieving it in the next few weeks, I am working on setting up a control system for my pool, and also our outdoor lighting, there are 4 relays i have wired, one for main pump, one for booster pump, one for spa blower, and one for the outdoor lighting, the relays are wired to the diode and transistor so they can be controlled by the arduino, all the wiring is setup and should be fine, i have even put a schematic on here if it helps at all, I am using the arduino 0022 software to write the code, i have copied the code from http://www.atari-source.org/node/65 and modifed it for my own uses, but i am unable to compile it be cause it errors out, same with the code when i copy it directly from the website in its full, unaltered state...
also in the schematic, there are two temperature sensors, which i havent coded yet, because i simply, do not know how to do it...
Here is my code so far
#include
int state_FilterPump=0, state_BoosterPump=0, state_SpaBlower=0, state_Lighting=0;
bool have_control=false; // Temp variable
int control_relay=0; // Temp variable
void setup()
{
pinMode(2, OUTPUT); // sets the digital pin as output
pinMode(4, OUTPUT); // sets the digital pin as output
pinMode(7, OUTPUT); // sets the digital pin as output
pinMode(8, OUTPUT); // sets the digital pin as ouput
// Prepare the serial ports
Serial.begin(9600);
Serial.flush();
}
void loop()
{
int serial_byte=0;
if (Serial.available()>0)
{
/* Here we wait for the first byte of a two byte control sequence. Send A, B or C to control filterpump,boosterpump, light, or blower.
*/
serial_byte=Serial.read();
if (!have_control)
{
have_control=true;
if (serial_byte=='A')
control_relay=2
else if (serial_byte=='B')
control_relay=4
else if (serial_byte=='C')
control_relay=7;
else if (serial_byte=='D')
control_relay=8;
// We have the control byte, now lets look for 1 or 0
if (serial_byte=='1')
{
// Turn specified relay on
if (control_relay==2
state_FilterPump=HIGH;
if (control_relay==4
state_BoosterPump=High;
if (control_relay==7
state_SpaBlower=HIGH;
if (control_relay==8
state_Lighting=HIGH;
}
else if (serial_byte=='0')
{
// Turn specified relay off
if (control_relay==2)
state_FilterPump=LOW;
if (control_relay==4)
state_BoosterPump=LOW;
if (control_relay==7)
state_SpaBlower=LOW;
If (control_relay==8)
state_Lighting=LOW;
}
What am i doing wrong, why cant i compile it, and is there any way to make it simpler? because of the fact i dont have the arduino yet, i can only assume i would turn on the relays by issueing a A1, B1, C1, or D1 command, and turn off the relays by issueing a A0, B0, C0, or D0 command
also in the schematic, there are two temperature sensors, which i havent coded yet, because i simply, do not know how to do it...
Here is my code so far
#include
int state_FilterPump=0, state_BoosterPump=0, state_SpaBlower=0, state_Lighting=0;
bool have_control=false; // Temp variable
int control_relay=0; // Temp variable
void setup()
{
pinMode(2, OUTPUT); // sets the digital pin as output
pinMode(4, OUTPUT); // sets the digital pin as output
pinMode(7, OUTPUT); // sets the digital pin as output
pinMode(8, OUTPUT); // sets the digital pin as ouput
// Prepare the serial ports
Serial.begin(9600);
Serial.flush();
}
void loop()
{
int serial_byte=0;
if (Serial.available()>0)
{
/* Here we wait for the first byte of a two byte control sequence. Send A, B or C to control filterpump,boosterpump, light, or blower.
*/
serial_byte=Serial.read();
if (!have_control)
{
have_control=true;
if (serial_byte=='A')
control_relay=2
else if (serial_byte=='B')
control_relay=4
else if (serial_byte=='C')
control_relay=7;
else if (serial_byte=='D')
control_relay=8;
// We have the control byte, now lets look for 1 or 0
if (serial_byte=='1')
{
// Turn specified relay on
if (control_relay==2
state_FilterPump=HIGH;
if (control_relay==4
state_BoosterPump=High;
if (control_relay==7
state_SpaBlower=HIGH;
if (control_relay==8
state_Lighting=HIGH;
}
else if (serial_byte=='0')
{
// Turn specified relay off
if (control_relay==2)
state_FilterPump=LOW;
if (control_relay==4)
state_BoosterPump=LOW;
if (control_relay==7)
state_SpaBlower=LOW;
If (control_relay==8)
state_Lighting=LOW;
}
What am i doing wrong, why cant i compile it, and is there any way to make it simpler? because of the fact i dont have the arduino yet, i can only assume i would turn on the relays by issueing a A1, B1, C1, or D1 command, and turn off the relays by issueing a A0, B0, C0, or D0 command