#include <16F88.h>
#device ADC = 10
#fuses NOWDT,NOPUT,XT,NOMCLR,NOLVP,NOWRT,NODEBUG,NOPROTECT,NOIESO
#use delay(clock=1000000)
void main()
{
set_tris_a(0xfc);
set_tris_b(0xf2);
//port_b_pullups(TRUE);
for(;;)
{
if((input(PIN_B1)==0)||(input(PIN_B4)==0)||(input(PIN_B6)==0)||(input(PIN_B7)==0))
//if(input(PIN_B1))
{
output_low(PIN_A1);
delay_ms(1000);
}
else
{
output_high(PIN_A1);
delay_ms(1000);
}
}
}
楼主试试这个程序吧 说真的
CCSC真是太高级了 好多底层的东西都给封装好了
所以想操作底层
可以这样做:
#include <16F88.h>
#device ADC = 10
#fuses NOWDT,NOPUT,XT,NOMCLR,NOLVP,NOWRT,NODEBUG,NOPROTECT,NOIESO
#use delay(clock=1000000)
#byte PORTA = 0x05
#byte PORTB = 0x06
#byte TRISA = 0x85
#byte TRISB = 0x86
#bit PORTA0 = PORTA.0
#bit PORTA1 = PORTA.1
#bit PORTA2 = PORTA.2
#bit PORTA3 = PORTA.3
#bit PORTA4 = PORTA.4
#bit PORTA5 = PORTA.5
#bit PORTA6 = PORTA.6
#bit PORTA7 = PORTA.7
#bit PORTB0 = PORTB.0
#bit PORTB1 = PORTB.1
#bit PORTB2 = PORTB.2
#bit PORTB3 = PORTB.3
#bit PORTB4 = PORTB.4
#bit PORTB5 = PORTB.5
#bit PORTB6 = PORTB.6
#bit PORTB7 = PORTB.7
#bit TRISA0 = TRISA.0
#bit TRISA1 = TRISA.1
#bit TRISA2 = TRISA.2
#bit TRISA3 = TRISA.3
#bit TRISA4 = TRISA.4
#bit TRISA5 = TRISA.5
#bit TRISA6 = TRISA.6
#bit TRISA7 = TRISA.7
#bit TRISB0 = TRISB.0
#bit TRISB1 = TRISB.1
#bit TRISB2 = TRISB.2
#bit TRISB3 = TRISB.3
#bit TRISB4 = TRISB.4
#bit TRISB5 = TRISB.5
#bit TRISB6 = TRISB.6
#bit TRISB7 = TRISB.7
void main()
{
TRISA = 0xFC;
TRISB = 0xFC;
//set_tris_a(0xfc);
//set_tris_b(0xf2);
//port_b_pullups(TRUE);
for(;;)
{
//if((input(PIN_B1)==0)||(input(PIN_B4)==0)||(input(PIN_B6)==0)||(input(PIN_B7)==0))
if((PORTB0==1)&&(PORTB4==1)&&(PORTB6==1)&&(PORTB7==1))
//if(input(PIN_B1))
{
//output_low(PIN_A1);
PORTA1 = 0;
delay_ms(1000);
}
else
{
//output_high(PIN_A1);
PORTA1 = 1;
delay_ms(1000);
}
}
}
这样才可以直接对底层直接操作
|