Autor Tema: control de acceso iButton-pic18F4550  (Leído 1883 veces)

0 Usuarios y 2 Visitantes están viendo este tema.

Desconectado MelissaP

  • PIC10
  • *
  • Mensajes: 1
control de acceso iButton-pic18F4550
« en: 15 de Diciembre de 2008, 18:50:58 »
Hola, necesito hacer un control de acceso con iButton y el pic 18F4550, en CCS, he revisado varios temas que hay en el foro que tienen mucho q ver, el problema es q me pierdo al intentar ntender los programas, me busque la libreria EX_TOUCH.c pero en realidad no se q es lo q hace, obvio q es leer el codigo del pic pero comando a comando no entiendo... :? si pudiesen ayudarme les agradeceria.

Les publico un programilla q encontre pero no he probado porq quiero saber q es lo que hace paso a paso. agradezco su ayuda!

#include <18F4550.h>
#ifndef TOUCH_PIN
#define TOUCH_PIN PIN_B0
#if defined(__PCW__)
#bit TOUCH_PIN_BIT = 0xF8A.0
#else
#bit TOUCH_PIN_BIT = 6.0
#endif
#endif
#use delay(clock=4M)

void main()
{
BYTE touch_read_byte() {
BYTE i,data;

for(i=1;i<=8;++i) {
output_low(TOUCH_PIN);
delay_us(14);
output_float(TOUCH_PIN);
delay_us(5);
shift_right(&data,1,input(TOUCH_PIN));
delay_us(100);
}
return(data);
}

BYTE touch_write_byte(BYTE data) {
BYTE i;

for(i=1;i<=8;++i) {
output_low(TOUCH_PIN);
delay_us(10);
if(shift_right(&data,1,0)) {
output_high(TOUCH_PIN);
delay_us(10);
if(!TOUCH_PIN_BIT)
return(0);
} else {
output_low(TOUCH_PIN);
delay_us(10);
if(TOUCH_PIN_BIT)
return(0);
}
delay_us(50);
output_high(TOUCH_PIN);
delay_us(50);
}
return(TRUE);
}

BYTE touch_present() {
BOOLEAN present;

output_low(TOUCH_PIN);
delay_us(500);
output_float(TOUCH_PIN);

delay_us(5);

if(!input(TOUCH_PIN))
return(FALSE);
delay_us(65);
present=!input(TOUCH_PIN);
delay_us(240);
if(present)
return(TRUE);
else
return(FALSE);
}}