ايران ويج

نسخه‌ی کامل: سوال یا یک کلید led 5 رو روشن کنم.
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
سلام چطور یبا یک کلید 5 ledرو روشن کنم.
با یک کلید چند عمل رو انجام بدم.
با دستور :
کد php:
DEBOUNCE Px.state label [ , SUB
Remarks

Px.y
A port pin like PINB.0 , to examine.

State
0 for jumping when PINx.y is low , 1 for jumping when PINx.y is high

Label
The label to GOTO when the specified state is detected

SUB
The label to GOSUB when the specified state is detected
مفهومه ؟
----------
یا ساده ترش :
if pinx = 1 then set portx

Debounce Pind.0 , 1 , Pr
وقتی pind.0 یک بشه (مثبت 5 ولت بهش وصل شه ) برنامه وارد لیبل pr میشه و داخل لیبل میتونین هر دستوری بزارین .

با این دستور هم میتونین مدت زمان نگه داشتن کلید رو به میلی ثانیه تعین کنید
config Debounce =x
میتونی از آیسی های دکودر ، مولتی پلکسر و... بسته به نیازت استفاده کنی.
کد php:
$regfile "m8def.dat"
$crystal 1000000
Config Portc 
Input
Config Portd 
Output
Dim A 
As Byte
Dim B 
As Byte
Dim C 
As Byte

Key Alias Pinc.0
Key1 Alias Pinc.1
Key2 Alias Pinc.2
  A 
1
Do
   
Locate 1 7
           Lcd A
   
If Key 1 Then
   waitms 200
   A 
1
   End 
If
   If 
Key1 1 Then
   Waitms 200
    A 
0
    Portd 
= &B00000000
    End 
If
    If 
Key2 1 Then
    Waitms 100
    A 
0
     End 
If
        
'halate 1
       If A = 2 Then Set Portd.0
       If A = 3 Then Set Portd.1
       If A = 4 Then Set Portd.2
       If A = 5 Then Set Portd.3
       If A = 6 Then Set Portd.4
       If A = 7 Then Set Portd.5
       If A = 8 Then Set Portd.6
       If A = 9 Then Set Portd.7
        If A = 10 Then
        Portd = &B0000000
        '
0
        End 
If
                     
'halate 2
         If A = 11 Then
         B = &B01111111
         For C = 0 To 7
         Rotate B , Left
         Waitms 50
         Portd = B
         Next C
         End If
                     '
halate 3
         
If 12 Then
         B 
= &B01111111
         
For 0 To 7
         Rotate B 
Right
         Waitms 50
         Portd 
B
         Next C
         End 
If
                     
'halate 4
         If A = 13 Then
         B = &B10000000
         For C = 0 To 7
         Rotate B , Right
         Waitms 50
         Portd = B
         Next C
         End If
                     '
halate 5

            
If 14 Then
         B 
= &B10000000
         
For 0 To 7
         Rotate B 
Right
         Waitms 50
         Portd 
B
         Next C
         End 
If

                       
'halate 6
            If A = 15 Then
        Portd = &B01010101
        Waitms 50
        Toggle Portd
        Waitms 500
         End If
                      '
halate 7

             
If 16 Then
        Portd 
= &B00110011
        Waitms 500
        Toggle Portd
        Waitms 50
         End 
If
                      
'halate 8
                If A = 17 Then
        Portd = &B00011100
        Waitms 500
        Toggle Portd
        Waitms 50
         End If

                         

Loop
End
Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.1 , Rs = Portb.0 
خب این چیه الان ؟ جوابته ؟ یا کدیه که مشکل داری توش ؟
این کد چرا ته برنامشه ؟؟
کد php:
Config Lcdpin Pin Db4 Portb.2 Db5 Portb.3 Db6 Portb.4 Db7 Portb.5 Portb.1 Rs Portb.0