Réponse à ma propre question ;)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
/*Bibliothèques*/
#include<p18f2520.h>
// inutile ici #include<stdio.h>
/*Equivalences*/
#define LED1 PORTBbits.RB0
#define LED2 PORTBbits.RB1
#define LED3 PORTBbits.RB2
#define LED4 PORTBbits.RB3
#define BOUTON PORTAbits.RA4
/*Prototypes de fonctions*/
void tempo(void);
void initialisation(void);
void initialisation(void)
{
unsigned char A;
A= PORTA;
TRISA=1; //PORTA configuré en entrée
A = PORTB;
TRISB=0; //PORTB configuré en sortie
PORTB=0; //initialise l'etat des LEDs
// return ; //fin de fonction
// void initialisation void à gauche signifie que tu renvoies rien: revoir prototypes de
// fonctions
}
void tempo(void)
{
unsigned int i,j; //déclaration de la variable
for (i=0;i<5;i++)
for (j=0;j<45500;j++); //tempo
// return; //fin de fonction
}
void tempo2(unsigned int ticks){
while(ticks--);
}
void main(void)
{
unsigned int count=0;
initialisation();
if(BOUTON==1){
//attendre l'appui du bouton
for(count=0;count<5;count++) //boucle de 5 tours
{
LED1=1; //allumer LED1
tempo(); //lancer la tempo
LED1=0; //eteindre LED1
LED2=1; //allumer LED2
tempo(); //lancer la tempo
LED2=0; //eteindre LED2
LED3=1; //allumer LED3
tempo(); //lancer la tempo
LED3=0; //eteindre LED3
LED4=1; //allumer LED4
tempo(); //lancer la tempo
LED4=0; //eteindre LED4
tempo(); //lancer la tempo
}
} |
Voici la réponse fournit rapidement par un de mes amis, j'espère quelle aidera d'autres personnes que moi. Il manque la partie initialisation : configuration de l'horloge...
De nouveau MERCI pour vos réponses.++
Citation:
Apprendre, partager, tant qu'il y a de l'échange,y'a de l'espoir.
Grand Corps Malade.