My code will not recognize the second part of the "AND" condition.
My "light" is greater than 200 and my "volt" is greater than 820 but digitalWrite 7 (relay) will not turn on.
Only the LED turns on.
I have verified this via the serial monitor.
I have listed the faulty code below:
int light;
int volt;
void setup()
{
pinMode(13, OUTPUT); // put your setup code here, to run once:
pinMode(7, OUTPUT);
Serial.begin(9600);
}
void loop()
{
light = analogRead(A0); // put your main code here, to run repeatedly:
volt = analogRead (A4);
//*********************
if (light > 200 && volt > 820)
{
digitalWrite(13, HIGH); // LED on:
digitalWrite(7, HIGH); // Relay on:
}
I used this to keep the relay looping high until my battery voltage drops below 660 then I will implement a delay to allow for battery recharge.
I just don't want the loop to stop until the voltage actually drops below 660.
Also I tried compiling your code and it stops at the ". . ." and an error message says "expected primary-expression before '.' token"
Thanks,
Hi Johnwasser,
I am using a relay shield without an external 5V power supply. The digital out high is providing the power to close the relay straight from the arduino.
I am using a relay shield without an external 5V power supply. The digital out high is providing the power to close the relay straight from the arduino.
Thanks,
So you have a special low-power 5V relay where the coil current is well below the 40mA "Absolute Maximum" of the Arduino pin?