mich29800

fonctiondelay

Dec 11th, 2020
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. boolean volatile clignote=1;
  3. boolean volatile led=1;
  4. void setup(){
  5.   cli();
  6.   TCCR1A = 0;TCCR1C = 0;TCNT1 = 0;        
  7.   TCCR1B = ( 1<<WGM12) | (1<<CS12) | (0<<CS11) | (1<<CS10) ;  
  8.   OCR1A = 3680;                                              
  9.   TIMSK1 = 1 << OCIE1A;                                      
  10.   sei();
  11.  }
  12. void loop() {
  13. delay(5000); //la led clignote pendant 5s
  14. clignote=0;digitalWrite(13,0);
  15. delay(5000); //la led est éteinte pendant 5s
  16. clignote=1;
  17. }
  18. ISR(TIMER1_COMPA_vect)
  19. {if (clignote==1){digitalWrite(13,led);led=!led;}}
Advertisement
Add Comment
Please, Sign In to add comment