Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <avr/io.h>
  3. #include <avr/interrupt.h>
  4. #include <util/delay.h>
  5. #include <alloca.h>
  6. #include <avr/cpufunc.h>
  7.  
  8.  
  9. uint8_t j = 1;
  10.  
  11. int main(void){
  12.     uint8_t i = 0;
  13.  
  14.     DDRA = 0xff;
  15.     DDRB = 0x00;
  16.     PORTB = 0xFF;
  17.  
  18.     char *p = malloc(256*sizeof(char));
  19.    
  20.     for(i=0;i<256;i++){
  21.         p[i] = j;
  22.         j = (j<<1)&0xff;
  23.         if(j == 0){ j = 1; }
  24.     }
  25.    
  26.     while(1){
  27.         if(PINB == 0x2a){
  28.             p[i] = (p[i] + 2)&0xff;
  29.         }
  30.         PORTA = p[i]&0xff;
  31.         i++;
  32.         if(i==256){i=0;}
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement