Programme DIGICODE en C

Fermé
walid.barjani Messages postés 2 Date d'inscription dimanche 22 juin 2014 Statut Membre Dernière intervention 23 juin 2014 - 22 juin 2014 à 20:17
 etudiant123 - 2 mars 2015 à 11:47
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

Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 2
23 juin 2014 à 08:49
Salut,

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

D'avance merci.
1
walid.barjani Messages postés 2 Date d'inscription dimanche 22 juin 2014 Statut Membre Dernière intervention 23 juin 2014
23 juin 2014 à 12:44
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
c'est nul
0