Last active
February 15, 2020 19:18
-
-
Save arduinothai/afba4d2de1c2a9ff0877785af945ed6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double sensorValue=0; | |
double sensorValue1=0; | |
int crosscount=0; | |
int climbhill=0; | |
double VmaxD=0; | |
double VeffD; | |
double Veff; | |
void setup() { | |
Serial.begin(115200); | |
} | |
void loop() { | |
sensorValue1=sensorValue; | |
delay(100); | |
sensorValue = analogRead(A0); | |
if (sensorValue>sensorValue1 && sensorValue>511){ | |
climbhill=1; | |
VmaxD=sensorValue; | |
} | |
if (sensorValue<sensorValue1 && climbhill==1){ | |
climbhill=0; | |
VmaxD=sensorValue1; | |
VeffD=VmaxD/sqrt(2); | |
Veff=(((VeffD-420.76)/-90.24)*-210.2)+210.2; | |
Serial.println(Veff); | |
VmaxD=0; | |
} | |
} | |
//ที่มา http://sentroino.blogspot.com/2015/12/measuring-ac-voltage-using-arduino.html?m=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment