Hello guys.My project purpose was to measure voltages and show it through pc with visual basic 6.I finished it, it works fine but the way i did it seems wrong and complicated.Any suggestion to improve my code and learn more?
pic programm
VB6 program
pic programm
Rich (BB code):
while(TRUE){
set_adc_channel(0);
delay_ms(10);
binary0=read_adc();
value0=(((float)binary0/1023)*(5));
printf("1");
printf("%2.3f",value0);
delay_ms(200);
set_adc_channel(1);
delay_ms(10);
binary1=read_adc();
value1=((float)binary1/1023)*(5);
printf ("2");
printf ("%2.3f",value1);
delay_ms(200);
set_adc_channel(2);
delay_ms(10);
binary2=read_adc();
value2=(((float)binary2/1023)*(5));
printf("3");
printf("%2.3f",value2);
delay_ms(200);
}
Rich (BB code):
i = MS1.Input
If i = 1 Then
MS1.InputLen = 5
btr = 5
Do
DoEvents
Loop Until MS1.InBufferCount >= btr
datain = MS1.Input
Label1.Caption = datain & "V"
MS1.InputLen = 1
End If
If i = 2 Then
MS1.InputLen = 5
btr = 5
Do
DoEvents
Loop Until MS1.InBufferCount >= btr
datain = MS1.Input
Label3.Caption = datain & "V"
MS1.InputLen = 1
End If
If i = 3 Then
MS1.InputLen = 5
btr = 5
Do
DoEvents
Loop Until MS1.InBufferCount >= btr
datain = MS1.Input
Label4.Caption = datain & "V"
MS1.InputLen = 1
End If