I am trying to utilize the email client example (http://playground.arduino.cc/Code/Email
) in order to send an email when an LED on an external circuit turns on. I am naming pin A0 as analogPin and the following code is what my void setup and loop is. The rest of the code (other than the email addresses and IPs) remains the same.
int analogPin = A0;
Ethernet.begin(mac, ip, gateway, gateway, subnet);
int analogValue = analogRead(analogPin);
int currentVolt = analogRead(A0);
float voltage = currentVolt * (5.0 / 1023.0);
if(voltage > 1.9)
Pin A0 is attached to the LED, so that when the LED is on, a voltage (about 1.9 volts) is present. This should be read by the arduino, and the sendEmail command should run.
The code compiles perfectly, but my problem is that whenever I upload this to the Arduino, it begins to send emails constantly, even with the LED is not lit. When I complete the circuit to turn the LED on, the Arduino stops sending emails. I cannot figure out how to get the Arduino to send only one email, as well as why it is doing the opposite of what I want it to.
If anyone could please help that would be great.