Created
May 16, 2017 14:30
-
-
Save proto-pic/07fa3a3bc98294201dba2414bc2771e5 to your computer and use it in GitHub Desktop.
Arduino Volt Meter - V2
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
int myVoltageReading = 5.14; | |
unsigned int analogIn = 0; | |
void setup() | |
{ | |
Serial.begin(115200); | |
} | |
void loop() | |
{ | |
analogIn = analogRead(A0); | |
analogIn = map(analogIn, 0, 1023, 0, myVoltageReading * 1000); | |
Serial.print("@"); | |
if (analogIn < 10) Serial.print("0"); | |
if (analogIn < 100) Serial.print("0"); | |
if (analogIn < 1000) Serial.print("0"); | |
if (analogIn < 10000) Serial.print("0"); | |
Serial.print(analogIn, DEC); | |
Serial.print("#"); | |
delay(150); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment