SHARE
TWEET

Untitled

a guest Oct 17th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define F_CPU 16000000UL
  2. #define DISPLAY 4
  3.  
  4. #include <avr/io.h>
  5. #include <util/delay.h>
  6.  
  7. unsigned char segmets[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e} ;
  8. unsigned int io[] = {0x01, 0x02, 0x04, 0x08} ;
  9.  
  10. unsigned int num, digit, a;
  11. unsigned char i;
  12.  
  13. int main()
  14. {
  15.     num = 1234;
  16.     i= 0;
  17.     DDRA = 0xff;
  18.     DDRB = (1<<PA0) |(1<<PA1)|(1<<PA2)|(1<<PA3);
  19.     while(1)
  20.     {
  21.         if(i <= DISPLAY)
  22.         {
  23.             a = num%10;
  24.             PORTA= segmets[a];
  25.             PORTB = io[i++];
  26.         }
  27.         else
  28.         {
  29.             i=0;
  30.         }
  31.     }
  32. }
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