program Chenillard_001; var LedD1: sbit at GPIO.5; LedD2: sbit at GPIO.4; LedD3: sbit at GPIO.2; LedD4: sbit at GPIO.1; LedD5: sbit at GPIO.0; ActiveLeds : Byte; procedure init(); begin TRISIO := 0x08; // On configure l'entrée GP3 en entrée GPIO := 0x00; // On met les sorties à l'état logique bas "0" CMCON := 0x07; // On désactive le module de comparaison ADCON0 := 0x00; // On désactive le module Analogique Numérique (pas de consommation de courant) ANSEL := 0x00; // On configure toutes les broches en sortie numérique TMR1ON_bit := 1; // On active le TIMER1 T1CKPS0_bit := 1; //| T1CKPS1_bit := 1; //| On configure le prescaler à 1:8 TMR1CS_bit := 0; // On utlise l'horloge interne (Fosc/4) INTCON.GIE := 1; // On active les interruptions générales INTCON.PEIE := 1; // et on active les masques d'interrutpion PIE1.TMR1IE := 1; // On active les interruptions du TIMER1 PIR1.TMR1IF := 0; // On met à zéro le drapeau de débordement TMR1L := 0x00; // On commence à zéro pour compter! TMR1H := 0x00; ActiveLeds := 1; // Permet d'activer à tour de rôle les leds end; procedure interrupt(); begin if (GPIO.GP3 = 1) then begin if ((PIR1.TMR1IF = 1) and (ActiveLeds = 1)) then begin LedD1 := 1; LedD2 := 0; LedD3 := 0; LedD4 := 0; LedD5 := 1; ActiveLeds := 2; PIR1.TMR1IF := 0; end; if ((PIR1.TMR1IF = 1) and (ActiveLeds = 2)) then begin LedD1 := 1; LedD2 := 1; LedD3 := 0; LedD4 := 0; LedD5 := 0; ActiveLeds := 3; PIR1.TMR1IF := 0; end; if ((PIR1.TMR1IF = 1) and (ActiveLeds = 3)) then begin LedD1 := 0; LedD2 := 1; LedD3 := 1; LedD4 := 0; LedD5 := 0; ActiveLeds := 4; PIR1.TMR1IF := 0; end; if ((PIR1.TMR1IF = 1) and (ActiveLeds = 4)) then begin LedD1 := 0; LedD2 := 0; LedD3 := 1; LedD4 := 1; LedD5 := 0; ActiveLeds := 5; PIR1.TMR1IF := 0; end; if ((PIR1.TMR1IF = 1) and (ActiveLeds = 5)) then begin LedD1 := 0; LedD2 := 0; LedD3 := 0; LedD4 := 1; LedD5 := 1; ActiveLeds := 1; PIR1.TMR1IF := 0; end; end; if (GPIO.GP3 = 0) then begin if ((PIR1.TMR1IF = 1) and (ActiveLeds = 1)) then begin LedD1 := 1; LedD2 := 0; LedD3 := 0; LedD4 := 0; LedD5 := 0; ActiveLeds := 2; PIR1.TMR1IF := 0; end; if ((PIR1.TMR1IF = 1) and (ActiveLeds = 2)) then begin LedD1 := 0; LedD2 := 1; LedD3 := 0; LedD4 := 0; LedD5 := 0; ActiveLeds := 3; PIR1.TMR1IF := 0; end; if ((PIR1.TMR1IF = 1) and (ActiveLeds = 3)) then begin LedD1 := 0; LedD2 := 0; LedD3 := 1; LedD4 := 0; LedD5 := 0; ActiveLeds := 4; PIR1.TMR1IF := 0; end; if ((PIR1.TMR1IF = 1) and (ActiveLeds = 4)) then begin LedD1 := 0; LedD2 := 0; LedD3 := 0; LedD4 := 1; LedD5 := 0; ActiveLeds := 5; PIR1.TMR1IF := 0; end; if ((PIR1.TMR1IF = 1) and (ActiveLeds = 5)) then begin LedD1 := 0; LedD2 := 0; LedD3 := 0; LedD4 := 0; LedD5 := 1; ActiveLeds := 1; PIR1.TMR1IF := 0; end; end; end; begin init(); while true do begin // On ne fait rien dans le programme principal end; end.