eiby
Joined: 07 Oct 2008 Posts: 3
|
Detecting a change of state 16F877A |
Posted: Sun Nov 09, 2008 8:44 pm |
|
|
Hi. I have a problem with detection. I need to know how make the code for detecting that a bit is changing less than every 2 seconds, but without using interrupts, because this part of the code have to activate a while statement that is reading the same bits and incrementing a variable.
If the bits change state in more than 2 seconds the while statement have to be finished to go on with the rest of the code.
Do I make myself clear ?
Hope you can help. This is a part of the code:
Code: |
#include <16F877A.h>
#define fila1 input_state(pin_a1)
#define fila2 input_state(pin_a2)
#define fila3 input_state(pin_a3)
cont_fast:
while(??????????){
lcd_gotoxy(1,2);
printf(lcd_putc,"%Lu",cuenta);
if(fila1==1){
++cuenta;
output_low(fila2);
output_low(fila3);
delay_ms(10); //tiempo de caida para filas 2 y 3
}
if(fila2==1){
++cuenta;
output_low(fila3);
delay_ms(5);
}
if(fila3==1){
++cuenta;
}
|
_________________ Best regards,,
Abraham Guerrero |
|