Buton Uygulaması (Butona bastıkça 0-9 arası sayaç)


#include <p18f4550.h>
#include <delays.h>
//                                    hgfedcba     ortak cathod display için
#define SIFIR          0b00111111
#define BIR             0b00000110
#define IKI              0b01011011
#define UC              0b01001111
#define DORT         0b01100110
#define BES            0b01101101
#define ALTI           0b01111101
#define YEDI           0b00000111
#define SEKIZ        0b01111111
#define DOKUZ      0b01101111
#define buton PORTDbits.RD7  // buton değişkeni portd'nin 7. biti olarak tanımlandı
// butona basdıkca 0-9 arası sayar
void main(void){
char segment[]={SIFIR,BIR,IKI,UC,DORT,BES,ALTI,YEDI,SEKIZ,DOKUZ};
int i=0;
TRISD=0b10000000;
while(1)
{
PORTD=segment[i];
Delay10KTCYx(100);
i++;
if(i==10)
i=0;
while(buton==0); // buton    PORTD'nin 7. pini 1 oluncaya kadar bekle
}
}
DEVRE ŞEMASI

Yorumlar