Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Need Conditional output for lcd voltmeter

Status
Not open for further replies.

khaled01819

Newbie level 6
Newbie level 6
Joined
May 27, 2010
Messages
11
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Location
bangladesh
Visit site
Activity points
1,370
Hi All, I am very new here
I have collect the following c-code for 20V LCD Voltmeter using pic16F688, now i want to activate RA0 pin high when LCD voltage is grater than or equal 10.0v, what is the change need in this code? Please help....

char Message1[] = "DVM Project";
unsigned int ADC_Value, DisplayVolt;
char *volt = "00.0";

void main() {

ANSEL = 0b00000100; // RA2/AN2 is analog input
ADCON0 = 0b00001000; // Analog channel select @ AN2
ADCON1 = 0x00; // Reference voltage is Vdd
CMCON0 = 0x07 ; // Disable comparators
TRISC = 0b00000000; // PORTC All Outputs
TRISA = 0b00001100; // PORTA All Outputs, Except RA3 and RA2
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,Message1);
Lcd_Chr(2,10,'V');

do {

ADC_Value = ADC_Read(2);
DisplayVolt = ADC_Value * 2;
volt[0] = DisplayVolt/1000 + 48;
volt[1] = (DisplayVolt/100)%10 + 48;
volt[3] = (DisplayVolt/10)%10 + 48;
Lcd_Out(2,5,volt);
delay_ms(500); // Hold for 500 ms

} while(1);
} // End main()
 

Then try :

PORTA0 = (volt[0] >= '1') ? 1 : 0;
or
PORTA.0 = (volt[0] >= '1') ? 1 : 0;
...

or perhaps

if (volt[0] >= '1')
PORTA |= 1;
else PORTA &= 0;
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top