اطلاعیه

Collapse
No announcement yet.

do--loop

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

    do--loop

    ُسلام دوستان
    من میخوام یه برنامه بنویسم یه کم گیج شدم.لطفا راهنمایی کنید
    من میخوام دو تا ال ای دی از پورت B به صورت دائم یکی در میون روشن شه و پورت c هم با افکتی که تو برنامه هست روشن شه ال ای دی ها.دو تا do-loop میخوام.ولی نمیشه تو بسکام دو تا گذاشت.درسته؟
    نظرتون چیه؟با چه فنی میشه اینکار رو کرد؟
    دوستان خیلی فوریه.نیاز دارم به برنامه.مرسی
    اینم برنامه

    $regfile "m8def.dat"
    $crystal = 1000000
    Config Portc = Output
    Config Portb = Output
    '------------------------------------------------

    Do
    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200
    Loop

    '---------------------------------------------


    Do
    Portc = &B00000001
    Wait 1
    Portc = &B00000011
    Wait 1
    Portc = &B00000111
    Wait 1
    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150
    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150
    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150
    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150
    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Wait 5
    Portc = &B00000000
    Loop
    End 'end program
    **** k i n j ****

    #2
    پاسخ : do--loop

    آقا یه راه واسه شما اینه که اون قسمت مربوط به portb رو با وقفه ی تایمر کار کنی یا هم داخل همین برنامه اونو بگونجونی :


    $regfile "m8def.dat"
    $crystal = 1000000
    Config Portc = Output
    Config Portb = Output
    '------------------------------------------------
    Do
    Portc = &B00000001

    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200

    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200


    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200


    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200


    Portc = &B00000011

    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200

    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200


    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200


    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200

    Portc = &B00000111

    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200

    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200


    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200


    Portb = &B00000001
    Waitms 200
    Portb = &B00000010
    Waitms 200

    Portb = &B00000001

    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150

    Portb = &B00000010

    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150

    Portb = &B00000001

    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150

    Portb = &B00000010

    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150

    Portb = &B00000001

    Portc = &B00000000
    Waitms 50
    Portc = &B00000111
    Waitms 150

    for f =1 to 12

    Portb = &B00000010
    Waitms 200
    Portb = &B00000001
    Waitms 200

    next

    Waitms 150

    Portc = &B00000000

    Waitms 50

    Portb = &B00000010

    waitms 150
    Loop
    End 'end program
    زاویه ی نگاهتو عوض کن . . .

    دیدگاه


      #3
      پاسخ : do--loop

      مرسی.دو تا ال ای دی پورت B یه کم کوچولو نا منظم میشه تو زمانش
      کسی ایده دقیق تر نداره؟ممنون میشم از کمکتون
      **** k i n j ****

      دیدگاه


        #4
        پاسخ : do--loop

        اون برنامه اصلیت رو بذار تو do - loop و اون دو تا پایه رو بذار تو یه وقفه تایمر.
        همونطور که جناب shadkanlu فرمودن.
        ?Why not

        دیدگاه


          #5
          پاسخ : do--loop

          مرسی دوستان.همون برنامه بالا رو کچلو اینور اونور کردم تو پرتوس جواب داد.حله دیگه؟
          **** k i n j ****

          دیدگاه

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