如何使用vb从pic读取数据。 [英] How to read data from pic using vb.

查看:119
本文介绍了如何使用vb从pic读取数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用vb从pic读取数据。例如,我想从pic读取电压并将其显示在文本框上。



这里我的图片代码:



how to read data from pic using vb. For example, I want to read voltage from pic and display it on textbox.

here my pic code:

unsigned long value;
float volt, voltscale;

char txt[13];
char txt2[4];
// LCD module connections
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;

sbit LCD_D7 at RB7_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D4 at RC4_bit;
// End LCD module connections

// LCD Pin direction
sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;

sbit LCD_D7_Direction at TRISB7_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D4_Direction at TRISC4_bit;
// End of LCD Pin direction

void main()

{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"Volt=");
Lcd_Out(1,15,"V");

 while(1){


    value=adc_read(0);
     volt=value*5.0/1024;

     voltscale=volt*100.0;
     floattostr(voltscale, txt);
     strncpy(txt2, txt, 4);
     txt2[4]='\0';
     Lcd_Out(1,4, txt2);

     delay_ms(200);
     if ( voltscale >= 275){
        UART1_Write('overvoltage');}

      if ( voltscale <= 215){
        UART1_Write('undervoltage');}


     }
}





vb代码:



vb code:

Label9.Text = SerialPort1.ReadExisting()

推荐答案

我们无法回答这个问题。

有太多的变量,从你正在使用的连接开始,继续你编程的那种输出进入PIC。



首先查看 SerialPort类 [ ^ ]并从那里开始工作。
We can't answer that.
There are way, way too many variables, starting with what connection you are using, and continuing to what kind of output you programmed into the PIC.

Start by looking at the SerialPort class[^] and work your way from there.


这篇关于如何使用vb从pic读取数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆