Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Created May 17, 2018 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arduinothai/3fa533659bf5b1d745dedb6ed20b5da4 to your computer and use it in GitHub Desktop.
Save arduinothai/3fa533659bf5b1d745dedb6ed20b5da4 to your computer and use it in GitHub Desktop.
#include <Wire.h>
#define VT_PIN A0 // connect VT
#define AT_PIN A1 // connect AT
#define ARDUINO_WORK_VOLTAGE 5.0
void setup(){
Serial.begin(9600);
pinMode(VT_PIN,INPUT);
pinMode(AT_PIN,INPUT);
}
void loop(){
int vt_temp = analogRead(VT_PIN);
int at_temp = analogRead(AT_PIN);
double voltage = vt_temp * (ARDUINO_WORK_VOLTAGE / 1023.0) * 5;
double current = at_temp * (ARDUINO_WORK_VOLTAGE / 1023.0);
Serial.print("Voltage= " + (String)voltage + "V ");
Serial.println("Current= " + (String)current + "A ");
delay(500);
}
//ที่มา : http://rdiot.tistory.com/54 [RDIoT Demo]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment