Created
May 17, 2018 18:50
-
-
Save arduinothai/3fa533659bf5b1d745dedb6ed20b5da4 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
#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