Advertisement
miszczo

Untitled

Feb 28th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. uint32_t get_random()
  2. {
  3.         uint32_t wartosc = 0 ;
  4.         uint8_t i;
  5.  
  6.         for(i = 0;i<8;i++)
  7.         {
  8.                 //ustawienia adc, adc enable , preskaler 64 , start conversion
  9.                 ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADSC);
  10.                 while(ADCSRA&(1<<ADSC));                //wait for end conversion
  11.  
  12.                 wartosc = ((wartosc<<1) | (ADCL & 0x01));
  13.         }
  14.  
  15.         return (wartosc%10);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement