User manual
127 void loop()
128 {
129 double percent;
130 float voltage;
131 byte highbyte, lowbyte, crc;
132 int adc_raw = adc_AVG(ADC_CHANNEL);
133
134 voltage = (5.0 / 1024.0) * adc_raw;
135
136 lcd.setCursor(0, 0);
137 lcd.print(voltage, 2);
138 lcd.print(" V ");
139
140 percent = voltage / 5.0 * 100.0;
141 draw_bargraph(percent);
142
143 Serial.flush();
144 highbyte=adc_raw/256;
145 lowbyte=adc_raw%256;
146 Serial.write(highbyte);
147 Serial.write(lowbyte);
148 crc=170^highbyte^lowbyte;
149 Serial.write(crc);
150
151 delay(20);
152 }
To start the PC-program, you only need to execute the EXE file
in the folder ...\VOLTMETER\vb.net\bin\Release. Then choose the
Comport, which is identical to the one you have already set in
the Arduino™-IDE for the program transfer. If you click Connect
now, the voltage in the PC-program will be displayed.
The VB.NET-program is enclosed as source code and can be used
as a basis for your own experiments. For this, you need to
download the free Visual-Basic-Express-Version by Microsoft.
You can find it
athttps://www.visualstudio.com/downloads/download-visual-stu
dio-vs. When you have opened the program with Visual Basic, you
will see the source code and the designer before you. The designer
displays the visual control elements such as buttons, texts
fields, etc. Now have a look at the source code of the Voltmeter
program by switching to source code view.
001 Imports System.IO.Ports.SerialPort
002 Imports System.Text.Encoding
First, we will import the functions needed for the serial