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');} } }
Label9.Text = SerialPort1.ReadExisting()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)