Você está na página 1de 1

04-Jun-11

Xut nhp I/O


input_a() nhp t Port A
input_b() nhp t Port B
V d:
data = input_b();
input(pin) nhp t mt chn port
V d:
while ( !input(PIN_B1) );
// waits for B1 to go high
if( input(PIN_A0) )
printf("A0 is now high\r\n");

15

To xung vung
V d: To xung vung f=1 KHz ti chn
RB0 (Cch 1)
#include <16F84.h>
#use delay(clock=20000000)
Main()
{
while(1)
{
output_high(pin_B0);
delay_us(500); // delay 250us
output_low (pin_B0);
delay_us (500 );
}
}

V d: To xung vung f=1 KHz ti chn


RB0 (Cch 2)
#include <16F84.h>
#use delay(clock=20000000)
Main()
{
int1 x;
while(1)
{
output_bit(pin_B0,!x);
delay_us(500);
}
}

16

Você também pode gostar