SHARE
TWEET

Untitled

a guest Apr 25th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define red OCR0A
  2. #define green OCR0B
  3.  
  4.  
  5.  
  6. red = 253;                                                //
  7.  
  8. green = 254;                                            // starting point sets led to be red
  9.  
  10.                      
  11.        
  12.     while (1)                                                                   // while loop sets the colour by increamenting OCR0A and OCR0B
  13.   {  
  14.  
  15.         for (int i=0    ; i<252; i++){red--; _delay_ms(delay); } red=1;                          
  16.        
  17.        
  18.         for (int i=0    ; i<252; i++){green--; _delay_ms(delay); } green=2;
  19.        
  20.        
  21.         for (int i=0    ; i<252; i++){red++; green++; _delay_ms(delay); } red=253; green=254;      
  22.   }
  23.  
  24. ISR(TIMER0_COMPA_vect)
  25. {
  26.     PORTA &= ~(1<<greenLED);                                //green on
  27.     PORTD |= (1<<redLED);                                      //red off
  28. }
  29. ISR(TIMER0_COMPB_vect)
  30. {
  31.     PORTD &= ~(1<<blueLED);                                  //blue on  
  32.     PORTA |= (1<<greenLED);                                   //green off  
  33. }
  34. ISR(TIMER0_OVF_vect)
  35. {
  36.     PORTD &= ~(1<<redLED);                                  //red on  
  37.     PORTD |= (1<<blueLED);                                    //blue off  
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top