Rooney_04
Member level 2
hi
below is some programing code i did for binary sequence count. So i like to use push button as to count up and another push button to push down. So i would like how i can PIN_b0 and Pin_B1 as the input. how i can do that or the coding ?
#include <16F877a.h>
#include <stdio.h>
#include <stdlib.h>
#use delay(clock=20000000)
#fuses hs, noprotect, nowdt, nolvp
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
#byte portb=6
#byte portc=7
#byte portd=8
int k, datain;
void main()
{
k=0;
loop:
// Check Input
datain=input_b();
if( bit_test(datain,0) && !bit_test (datain,1) )
k++;
if( !bit_test(datain,0) && bit_test (datain,1) )
k--;
// Send Data to RS232
putc(k);
delay_ms(50);
goto loop;
}
below is some programing code i did for binary sequence count. So i like to use push button as to count up and another push button to push down. So i would like how i can PIN_b0 and Pin_B1 as the input. how i can do that or the coding ?
#include <16F877a.h>
#include <stdio.h>
#include <stdlib.h>
#use delay(clock=20000000)
#fuses hs, noprotect, nowdt, nolvp
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
#byte portb=6
#byte portc=7
#byte portd=8
int k, datain;
void main()
{
k=0;
loop:
// Check Input
datain=input_b();
if( bit_test(datain,0) && !bit_test (datain,1) )
k++;
if( !bit_test(datain,0) && bit_test (datain,1) )
k--;
// Send Data to RS232
putc(k);
delay_ms(50);
goto loop;
}