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.

ADC using 16F877A - there are errors in compiling the code

Status
Not open for further replies.

dania

Newbie level 1
Joined
Apr 5, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
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.. :cry:
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..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top