// ********************************************************************

//
// Arduino as DC voltmeter, 0-20 volt
//
// Code Samples voltage from analog pin5, in 1:1 (1023 = 5 v) and the mesure value is convertes into a string variable called whole.
// You simply call this object with a global char variable called voltage, and object returns the voltage value.
// This voltage value can be send by usb, ethershield to web, or webserver or a LCD display
//
// Free codesnip under GPL/GNU licens from//
// Date: 11 february 2012
// Publisher and project home: http://mynerdstuff.blogspot.com/
//
// Grab Schematic for the arduino voltage indput here: http://mynerdstuff.blogspot.com/2012/02/arduino-as-voltmeter.html
//
// ********************************************************************
void getvoltage(char *voltage)
{
int sign, whole;
sensor = 1;
sign=false;
if(sign) voltage[0]=’-';
else voltage[0]=’+';
// analog read
whole = 0;
whole = analogRead(5);
whole = whole/2;
voltage[1]= (whole % 10000)/1000 +’0′ ;
voltage[2]= (whole % 1000)/100 +’0′;
voltage[3]=’,';
voltage[4]= (whole % 100)/10 +’0′;
voltage[5]= (whole % 10)+’0′;
voltage[6] = ‘###BOT_TEXT###′;
delay(1000UL); // delay 30 sec
}