/* created by Bertrand VANDEPORTAELE */ const int inputPin = 12; //signal d'entrée const int ledPin = 13; //broche 13=PB5 char val=0; char cpt=0; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { // start serial port at 9600 bps: Serial.begin(115200); pinMode(ledPin, OUTPUT); pinMode(inputPin, INPUT); /* while(1) //pour test recopie simple { val = (PINB>>4) & 1; PORTB = (PORTB & 0xdf) | (val<<5); }*/ } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { while(1) { while( ( (PINB>>4) & 1)==0); //attente front montant cpt++; if (cpt>=5) //facteur de division /2 { delayMicroseconds(15); PORTB = (PORTB & 0xdf) | (val<<5); cpt=0; if (val==0) val=1; else val=0; } while( ( (PINB>>4) & 1)==1); //attente front descendant } }