dania
Newbie level 1
ADC using 16F877A
can anyone help me with my coding..i have create a c coding for my light intensity analysis. different intensity will light different LED.i used photodetector as sensor.but when i compile the code, there are errors..
can anyone tell me whats wrong with my coding.
#include <16f877a.h>
#device adc=8
#use delay(clock=20000000)
#fuses hs,noprotect,nowdt,nolvp
#byte PORTA=5
#byte PORTB=6
main()
{
int value;
set_tris_b(0);
setup_port_a(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
portb=255;
delay_ms(2000);
portb=0;
do
{
value=read_adc();
if(value<25)
{
portb=0b10000000;
}
else if(value>=25 && value< 50)
{
portb=0b01000000;
}
else
{
portb=0b00100000;
}
}
while(1);
}
thanks in advance..
can anyone help me with my coding..i have create a c coding for my light intensity analysis. different intensity will light different LED.i used photodetector as sensor.but when i compile the code, there are errors..
can anyone tell me whats wrong with my coding.
#include <16f877a.h>
#device adc=8
#use delay(clock=20000000)
#fuses hs,noprotect,nowdt,nolvp
#byte PORTA=5
#byte PORTB=6
main()
{
int value;
set_tris_b(0);
setup_port_a(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
portb=255;
delay_ms(2000);
portb=0;
do
{
value=read_adc();
if(value<25)
{
portb=0b10000000;
}
else if(value>=25 && value< 50)
{
portb=0b01000000;
}
else
{
portb=0b00100000;
}
}
while(1);
}
thanks in advance..