john120
Banned
- Joined
- Aug 13, 2011
- Messages
- 257
- Helped
- 11
- Reputation
- 22
- Reaction score
- 10
- Trophy points
- 1,298
- Activity points
- 0
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);
}
#device adc=10
setup_adc (ADC_CLOCK_DIV_8);
#include<16f877a.h>
#device ADC = 10 // Need to tell compiler ADC is configured for 10-bit reading
#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[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; //Changed this as there was error in the previous one
char display[2];
int value;
unsigned long volt;
unsigned int value2;
void main(){
set_tris_A(0xFF);
set_tris_B(0X00);
set_tris_D(0x00);
output_b(0);
output_d(0);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);
while(TRUE){
delay_us(100);
//value=read_adc(); //Not required
read_adc(ADC_START_ONLY);
delay_us(100);
value=read_adc(ADC_READ_ONLY);
volt=(value*500)/1023; //I changed this part of the code
value2=volt;
output_low(PIN_D1);
display[0]=value2/10;
output_high(PIN_D0);
output_B(digit[display[0]]);
delay_ms(10);
output_low(PIN_D0);
display[1]=value2%10;
output_high(PIN_D1);
output_B(digit[display[1]]);
delay_ms(10);
}
}
volt=(value*500)/1023; //I changed this part of the code
value2=volt;
output_low(PIN_D1);
display[0]=value2/10;
output_high(PIN_D0);
output_B(digit[display[0]]);
delay_ms(10);
output_low(PIN_D0);
display[1]=value2%10;
output_high(PIN_D1);
output_B(digit[display[1]]);
delay_ms(10);
display[0]=value2/10;
display[1]=value2%10;
#include<16f877a.h>
#device ADC = 10 // Need to tell compiler ADC is configured for 10-bit reading
#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[]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F}; //Changed this as there was error in the previous one
char display[2];
int value;
unsigned long volt;
unsigned int value2;
void main(){
set_tris_A(0xFF);
set_tris_B(0X00);
set_tris_D(0x00);
output_b(0);
output_d(0);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);
while(TRUE){
delay_us(100);
//value=read_adc(); //Not required
read_adc(ADC_START_ONLY);
delay_us(100);
value=read_adc(ADC_READ_ONLY);
volt=(value*500)/1023; //I changed this part of the code
value2=volt;
output_low(PIN_D1);
display[0]=value2/10;
output_high(PIN_D0);
output_B(digit[display[0]]);
delay_ms(10);
output_low(PIN_D0);
display[1]=value2%10;
output_high(PIN_D1);
output_B(digit[display[1]]);
delay_ms(10);
}
}
#include<16f877a.h>
#device ADC = 10 // Need to tell compiler ADC is configured for 10-bit reading
#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[]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F}; //Changed this as there was error in the previous one
char display[2];
int value;
unsigned long volt;
unsigned int value2;
void main(){
set_tris_A(0xFF);
set_tris_B(0X00);
set_tris_D(0x00);
output_b(0);
output_d(0);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);
while(TRUE){
if (input(PIN_A1) == 0){
delay_us(100);
//value=read_adc(); //Not required
read_adc(ADC_START_ONLY);
delay_us(100);
value=read_adc(ADC_READ_ONLY);
volt=(value*500)/1023; //I changed this part of the code
value2=volt;
output_low(PIN_D1);
display[0]=value2/10;
output_high(PIN_D0);
output_B(digit[display[0]]);
delay_ms(10);
output_low(PIN_D0);
display[1]=value2%10;
output_high(PIN_D1);
output_B(digit[display[1]]);
delay_ms(10);
}
else{
output_low(PIN_D0);
output_low(PIN_D1);
output_B(0);
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?