اطلاعیه

Collapse
No announcement yet.

رقص نور به زبان c

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    رقص نور به زبان c

    سلام
    کسی پروژه رقص نور ساده به زبان c داره؟

    #2
    پاسخ : رقص نور به زبان c


    unsigned char t = 1;
    while(1)
    {
    t = t<<1;
    t |= 0x01;
    if(t == 0xff)
    t = 0x01;
    }
    بت در بغل و به سجده پیشانی ما کافر زده خنده بر مسلمانی ما
    اسلام به ذات خود ندارد عیبی هر عیب که هست در این مسلمانی ماست

    دیدگاه


      #3
      پاسخ : رقص نور به زبان c

      خیلی ممنون
      لطف کردین

      میشه لطفا نحوه اتصالات رو هم با پروتئوس نشون بدین ؟
      باید چطور به 8051 وصل کنم؟

      دیدگاه


        #4
        پاسخ : رقص نور به زبان c

        برنامه قبلی که نوشتم یه خط کم داشت و wait هم یادم رفت:


        void wait (void) {
        ;
        }
        void main(){
        unsigned char t = 0xfe;
        unsigned int j;
        while(1)
        {
        P1 = t;
        t = t<<1;
        t |= 0x01;
        if(t == 0xff)
        t = 0xfe;
        for (j=0; j < 20000; j++)
        wait();
        }
        }

        این یکی هم پیشرفته تره که مثال خود KeilC51 هستش توی : Program Files\KeilC51\C51\Examples\BLINKY


        کد:
        /* BLINKY.C - LED Flasher for the Keil MCBx51 Evaluation Board with 80C51 device*/
                 
        #include <REG51F.H>
        
        // When you have enabled the option Stop Program Execution with Serial
        // Interrupt, the Monitor-51 uses the serial interrupt of the UART.
        // It is therefore required to reserve the memory locations for the interrupt
        // vector. You can do this by adding one of the following code lines:
        
        // char code reserve [3] _at_ 0x23; // when using on-chip UART for communication
        // char code reserve [3] _at_ 0x3; // when using off-chip UART for communication
        
        void wait (void) {         /* wait function */
         ;                 /* only to delay for LED flashes */
        }
        
        void main (void) {
         unsigned int i;          /* Delay var */
         unsigned char j;          /* LED var */
        
         while (1) {            /* Loop forever */
          for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */
           P1 = j;            /* Output to LED Port */
           for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
           wait ();           /* call wait function */
           }
          }
        
          for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */
           P1 = j;            /* Output to LED Port */
           for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
           wait ();           /* call wait function */
           }
          }
         }
        }

        http://rapidshare.com/files/124378463/flasher.zip.html
        بت در بغل و به سجده پیشانی ما کافر زده خنده بر مسلمانی ما
        اسلام به ذات خود ندارد عیبی هر عیب که هست در این مسلمانی ماست

        دیدگاه

        لطفا صبر کنید...
        X