Programme DIGICODE en C

walid.barjani Messages postés 2 Statut Membre -  
 etudiant123 -
bonjour ,

je voulais seulement savoir si mon code est juste ou pas , c'est un code pour programmer une pic 16F877 pour manipuler un clavier 16 touche (DIGICODE).

Merci ....

void init_port()
{
Trisa=0x00;
porta=0;
trisc=0X0F;
intcon =1;
}

void led_jaune()
{
RA0=1;
RA1=0;
RA2=0;
}

int calvier ()

{
if (RC0==1 && RC4==1) return 1;
if (RC0==1 && RC5==1) return 2;
if (RC0==1 && RC6==1) return 3;
if (RC0==1 && RC7==1) return 'A';
if (RC0==2 && RC4==1) return 4;
if (RC0==2 && RC5==1) return 5;
if (RC0==2 && RC6==1) return 6;
if (RC0==2 && RC7==1) return 'B';
if (RC0==3 && RC4==1) return 7;
if (RC0==3 && RC5==1) return 8;
if (RC0==3 && RC6==1) return 9;
if (RC0==3 && RC7==1) return 'C';
if (RC0==4 && RC4==1) return 'E';
if (RC0==4 && RC5==1) return 0;
if (RC0==4 && RC6==1) return 'F';
if (RC0==4 && RC7==1) return 'D';

}

int compare_tab(char *T1,int *T2)

{
for(int j=0;j<4;j++)

{
if (T1[j]==T2[j]) h=0;
else h=1;
}
return h;
}

void led_vert()
{
RA0=0;
RA1=0;
RA2=1;
}

void led_rouge()
{
RA0=0;
RA1=1;
RA2=0;
}

void main(void)

{ int i,x;
char T1[4],T2[4];

init_port ();
led_jaune ();
T1[0]=1;
T1[1]=2;
T1[2]=3;
T1[3]=4;
for(i=0;i<4;i++)
{
int t=clavier ();
T2[i]=t;
}
x = compare_tab();
if (x=0)
{
led_vert(); }
else led_rouge();

}

2 réponses

  1. Twinuts Messages postés 27 Date d'inscription   Statut Membre Dernière intervention   2
     
    Salut,

    Peux-tu stp modifier ton message en utilisant les balises de code.

    D'avance merci.
    1
  2. walid.barjani Messages postés 2 Statut Membre
     
    void init_port()
    {
    Trisa=0x00;
    porta=0;
    trisc=0X0F;
    intcon =1;
    }
    void led_jaune()
    {
    RA0=1;
    RA1=0;
    RA2=0;
    }
    int calvier ()
    {
    if (RC0==1 && RC4==1) return 1;
    if (RC0==1 && RC5==1) return 2;
    if (RC0==1 && RC6==1) return 3;
    if (RC0==1 && RC7==1) return 'A';
    if (RC0==2 && RC4==1) return 4;
    if (RC0==2 && RC5==1) return 5;
    if (RC0==2 && RC6==1) return 6;
    if (RC0==2 && RC7==1) return 'B';
    if (RC0==3 && RC4==1) return 7;
    if (RC0==3 && RC5==1) return 8;
    if (RC0==3 && RC6==1) return 9;
    if (RC0==3 && RC7==1) return 'C';
    if (RC0==4 && RC4==1) return 'E';
    if (RC0==4 && RC5==1) return 0;
    if (RC0==4 && RC6==1) return 'F';
    if (RC0==4 && RC7==1) return 'D';
    }
    int compare_tab(char *T1,int *T2)
    {
    for(int j=0;j<4;j++)
    {
    if (T1[j]==T2[j]) h=0;
    else h=1;
    }
    return h;
    }
    void led_vert()
    {
    RA0=0;
    RA1=0;
    RA2=1;
    }
    void led_rouge()
    {
    RA0=0;
    RA1=1;
    RA2=0;
    }
    void main(void)
    { int i,x;
    char T1[4],T2[4];
    init_port ();
    led_jaune ();
    T1[0]=1;
    T1[1]=2;
    T1[2]=3;
    T1[3]=4;
    for(i=0;i<4;i++)
    {
    int t=clavier ();
    T2[i]=t;
    }
    x = compare_tab();
    if (x=0)
    {
    led_vert(); }
    else led_rouge();
    }
    0
    1. etudiant123
       
      c'est nul
      0