View difference between Paste ID: e6X1HmrD and yirinrm6
SHOW: | | - or go back to the newest paste.
1
const int relay = 2;
2
const int sensorIn = A0;
3
int mVperAmp = 100; // use 100 for 20A Module and 66 for 30A Module
4
int relaystate;
5
double sensorVal;
6
double sensorVal1;
7
8
void setup() {
9
  Serial.begin(9600);
10
  pinMode(relay, OUTPUT);
11
  pinMode(sensorIn, INPUT);
12
  digitalWrite(relay, LOW);
13
}
14
15
void loop() {
16
17
  delay(500);
18
  relaystate = digitalRead(relay);   //Check if the fan is on/off
19
  sensorVal = sensorVal1 = getVPP();
20
  Serial.println(sensorVal); //Printing out the AmpsRMS
21
  Serial.println(sensorVal1);
22
23
  while (sensorVal >= .50) {
24
    digitalWrite(relay, HIGH);  //If the current is drawing, then turn on fan
25
    delay(3000);
26
    Serial.println(sensorVal);
27-
#    # this is always false
27+
28-
#    if (sensorVal1 < .50) { //If projector turns off, wait 1 minute and turn off fan
28+