john120
Banned
- Joined
- Aug 13, 2011
- Messages
- 257
- Helped
- 11
- Reputation
- 22
- Reaction score
- 10
- Trophy points
- 1,298
- Activity points
- 0
Hey,who could help me for reading temperature with LM35DZ and display it on 2 seven segment display.
I read on many links but the code did not help me.
I am using CCS C and common anode seven segment display driven by 2 NPN transistors BC337.
See the code here below:
#include<16f877a.h>
#fuses HS,NOWDT
#use delay(clock=20000000)
#include<stdio.h>
#include<STDLIB.H>
#use standard_io(A)
#use standard_io(B)
#use standard_io(D)
#define PORTB
#DEFINE PORTC
#define PORTA
byte const digit[]={0b1111001,0b0100100,0b0110000,0b0011001,0b001001 0,0b0000010,0b1111000,0b0000000,0b0010000};
char display[2];
int value;
int volt;
int value2;
void main()
{
set_tris_A(0xFF);
set_tris_B(0X00);
set_tris_D(0x00);
while(TRUE)
{
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);
{
delay_us(100);
value=read_adc();
read_adc(ADC_START_ONLY);
value=read_adc(ADC_READ_ONLY);
volt=(value/1023)*10;
value2=volt*100;
display[0]=value2%10;
output_high(PIN_D0);
output_B(digit[display[0]]);
delay_ms(10);
display[1]=(value2/10)%10;
output_high(PIN_D1);
output_B(digit[display[1]]);
delay_ms(10);
}
}
}
The seven segment are showing me 77 .when I measure the output of the LM35DZ I find 0.215Volts.
Help with code in ccs c plz!!!
I read on many links but the code did not help me.
I am using CCS C and common anode seven segment display driven by 2 NPN transistors BC337.
See the code here below:
#include<16f877a.h>
#fuses HS,NOWDT
#use delay(clock=20000000)
#include<stdio.h>
#include<STDLIB.H>
#use standard_io(A)
#use standard_io(B)
#use standard_io(D)
#define PORTB
#DEFINE PORTC
#define PORTA
byte const digit[]={0b1111001,0b0100100,0b0110000,0b0011001,0b001001 0,0b0000010,0b1111000,0b0000000,0b0010000};
char display[2];
int value;
int volt;
int value2;
void main()
{
set_tris_A(0xFF);
set_tris_B(0X00);
set_tris_D(0x00);
while(TRUE)
{
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);
{
delay_us(100);
value=read_adc();
read_adc(ADC_START_ONLY);
value=read_adc(ADC_READ_ONLY);
volt=(value/1023)*10;
value2=volt*100;
display[0]=value2%10;
output_high(PIN_D0);
output_B(digit[display[0]]);
delay_ms(10);
display[1]=(value2/10)%10;
output_high(PIN_D1);
output_B(digit[display[1]]);
delay_ms(10);
}
}
}
The seven segment are showing me 77 .when I measure the output of the LM35DZ I find 0.215Volts.
Help with code in ccs c plz!!!