Hello
I cant seem to make my relay module be in an off state before my code begins?
After I upload a sketch all the relays go High, I press my "Go" button switch starts the code but
at the first pass all the readings are wrong. This problem then goes away as the relays are now
all off. So when I press the go button again everything works fine.
I even tried to add another button that resets the relay before I press the other "Go" button.
Here is a portion of the code
#define RELAY1 6
#define RELAY2 7
#define RELAY3 8
#define RELAY4 9
#define RELAY5 10
#define RELAY6 11
int analogPin= 0;
int raw= 0;
int Vin= 5;
float Vout= 0;
float R1= 220;
float R2= 0;
float buffer= 0;
const int buttonPin = 2; // the number of the pushbutton pin
//const int buttonPin2 = 3; // the number of the pushbutton pin
//const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
//int buttonState2 = 0; // variable for reading the pushbutton status
void setup()
{
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
pinMode(RELAY5, OUTPUT);
pinMode(RELAY6, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
//pinMode(buttonPin2, INPUT_PULLUP);
Serial.begin(9600);
//Turn OFF any power to the Relay channels
digitalWrite(RELAY1,LOW);
digitalWrite(RELAY2,LOW);
digitalWrite(RELAY3,LOW);
digitalWrite(RELAY4,LOW);
digitalWrite(RELAY5,LOW);
digitalWrite(RELAY6,LOW);
delay(2000); //Wait 2 seconds before starting sequence
}
regards
Geoff