adc1= read_adc();
adc2=(adc1*5)/1023;
if(adc2>=your value)
{
turn on led
}
else
{
turn off led
}
Temp = ADC_Read(2);
if (Temp >= 680)
{
PORTB.F3 = 1;
}
else
{
PORTB.F3 = 0;
}
#include "16F877A.h"
#define PIC16F877 *=16 ADC=10
void main()
{
int adc_value;
int temp,adc1,adc2;
SET_TRIS_B( 0x00 );
SET_TRIS_A( 0xFF );
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(2); //channel 2 selected or pin RA2 selected for adc
setup_adc(ADC_CLOCK_DIV_8);
setup_adc_ports(PIN_A2);
adc1=read_adc();
adc2=(adc1*5)/1023;
if(adc2>=680)
{
temp=1;
}
else
{
temp=0;
}
#include "16F877A.h"
#define PIC16F877 *=16 ADC=10
void main()
{
int adc_value;
int temp,adc1,adc2;
SET_TRIS_B( 0x00 );
SET_TRIS_A( 0xFF );
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(2); //channel 2 selected or pin RA2 selected for adc
setup_adc(ADC_CLOCK_DIV_8);
setup_adc_ports(PIN_A2);
adc1=read_adc();
//adc2=(adc1*5)/1023; ------>>>> remove this line
if(adc1>=680) //------------>>> change here
{
temp=1;
}
else
{
temp=0;
}
#include "16F877A.h"
//#use delay(clock=4000000)
#device ADC=10
#fuses XT, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT
void main()
{
SET_TRIS_B( 0x00 );
SET_TRIS_A( 0xFF );
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(2); //channel 2 selected or pin RA2 selected for adc
setup_adc(ADC_CLOCK_DIV_8);
setup_adc_ports(RA2_ANALOG);
adc1=read_adc();
if(adc1>=680)
{
temp=1;
}
else
{
temp=0;
}
while (true)
{
if (input(PIN_A0))
{
output_high(PIN_B1);
if (input(PIN_A1)&& temp ==1 )
{
output_high(PIN_B3);
output_high(PIN_D0);
output_low(PIN_B2);
}
else
if ((input(PIN_A1)&& temp!=1)|| (!input(PIN_A1) && temp==1))
{
output_low(PIN_B3);
output_low(PIN_D0);
output_high(PIN_B2);
}
else
{
output_low(PIN_B3);
output_low(PIN_D0);
output_low(PIN_B2);
}
}
else
{
output_low(PIN_B1);
output_low(PIN_B3);
output_low(PIN_D0);
output_low(PIN_B2);
}
}
}
#include "16F877A.h"
#define PIC16F877 *=16 ADC=10
#fuses XT, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT
void main()
{
int temp,adc1;
SET_TRIS_B( 0x00 );
SET_TRIS_A( 0xFF );
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(2); //channel 2 selected or pin RA2 selected for adc
setup_adc(ADC_CLOCK_DIV_8);
setup_adc_ports(PIN_A2);
adc1=read_adc();
if(adc1>=680)
{
temp=1;
}
else
{
temp=0;
}
while (true)
{
if (input(PIN_A0))
{
output_high(PIN_B1);
if (input(PIN_A1)&& temp ==1 )
{
output_high(PIN_B3);
output_high(PIN_D0);
output_low(PIN_B2);
}
else
if ((input(PIN_A1)&& temp!=1)|| (!input(PIN_A1) && temp==1))
{
output_low(PIN_B3);
output_low(PIN_D0);
output_high(PIN_B2);
}
else
{
output_low(PIN_B3);
output_low(PIN_D0);
output_low(PIN_B2);
}
}
else
{
output_low(PIN_B1);
output_low(PIN_B3);
output_low(PIN_D0);
output_low(PIN_B2);
}
}
}
void main()
{
long value1,value2,value3;
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
while(1)
{
set_adc_channel(0);
delay_ms(10);
value1=read_adc();
if (value1>=680)
{
do any thing you want.
}
set_adc_channel(1);
delay_ms(10);
value2=read_adc();
if (value2>=500)
{
do any thing you want.
}
}
}
#include "16F877A.h"
#define PIC16F877 *=16 ADC=10
#fuses XT, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT
void main()
{
int16 adc1; //---------------> here
int temp; //---------------> and here
SET_TRIS_B( 0x00 );
SET_TRIS_A( 0xFF );
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(2); //channel 2 selected or pin RA2 selected for adc
setup_adc(ADC_CLOCK_DIV_8);
setup_adc_ports(PIN_A2);
adc1=read_adc();
if(adc1>=680)
{
temp=1;
}
else
{
temp=0;
}
while (true)
{
if (input(PIN_A0))
{
output_high(PIN_B1);
if (input(PIN_A1)&& temp ==1 )
{
output_high(PIN_B3);
output_high(PIN_D0);
output_low(PIN_B2);
}
else
if ((input(PIN_A1)&& temp!=1)|| (!input(PIN_A1) && temp==1))
{
output_low(PIN_B3);
output_low(PIN_D0);
output_high(PIN_B2);
}
else
{
output_low(PIN_B3);
output_low(PIN_D0);
output_low(PIN_B2);
}
}
else
{
output_low(PIN_B1);
output_low(PIN_B3);
output_low(PIN_D0);
output_low(PIN_B2);
}
}
}
#include "16F877A.h"
#use delay(clock=4M)
#define PIC16F877 *=16 ADC=10
#fuses XT, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT
#byte PORTB= 0x06
#byte TRISB= 0x86
int temp;
long value1;
void ADC()
{
set_adc_channel(0);
delay_ms(10);
value1=read_adc();
if (value1>=170)
{
temp=1;
}
else
{
temp=0;
} }
void main(void)
{
TRISB=0x00;
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
while (1)
{
ADC();
if (input(PIN_C1))
{
if (temp ==1 )
{
if (input(PIN_C2))
{PORTB=0x0d;
delay_ms(300);
PORTB=0x09;
delay_ms(200);
}
else
{ PORTB=0x03;}
}
else
{
if (input(PIN_C2))
{ PORTB=0x03;}
else
{ PORTB=0x01;}
}
}
else
{ PORTB=0x00;}
}}
#define PIC16F877 *=16 ADC=10
#include "16F877A.h"
#use delay(clock=4M)
//#define PIC16F877 *=16 ADC=10 // ---------->> What does this do?
#device adc=10 // ------------->> Try this
#fuses XT, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT
#byte PORTB= 0x06
#byte TRISB= 0x86
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?