Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Last active February 15, 2020 19:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arduinothai/afba4d2de1c2a9ff0877785af945ed6b to your computer and use it in GitHub Desktop.
Save arduinothai/afba4d2de1c2a9ff0877785af945ed6b to your computer and use it in GitHub Desktop.
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