آی پی امداد
abtahi
آریا الکترونیک mehrinfo تکشو

مشکل: روشن نشدن led در AVR با atmega 8

dr.mohammad

کاربر
2014-12-02
31
17
سلام!
من یک منو نوشتم که چند طبقه داره ولی در طبقه دوم وقتی از منو led رو انتخاب میکنی و از منو led کلید 1 که on هست میزنی led روشن نمیشه !!
قبلا کدشو نوشته بودم و تئوری درسته ولی نمیدونم چرا داخل پروتئوس کار نمیکنه یا اینکه مشکل از پروتئوس هست؟؟
کد:
$regfile = "m8def.dat"
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
Config Portc = Input
Config Portd = Output
Cursor Off
Cls
Do
Locate 1 , 3
Lcd ".::Menu::."


Locate 2 , 1
Lcd "1.LED"


Locate 2 , 11
Lcd "2.key"


If Pinc.1 = 1 Then Goto L1
If Pinc.2 = 1 Then Goto L2
Loop


L1:
Cls
Do
Locate 1 , 4
Lcd ".::LED::."


Locate 2 , 1
Lcd "1.ON"


Locate 2 , 6
Lcd "2.OFF"


Locate 2 , 12
Lcd "3.BK"


If Pinc.1 = 1 Then Pind.1 = 1


If Pinc.2 = 1 Then Pind.1 = 0


If Pinc.3 = 1 Then Goto L5
Loop


L5:
Do
Pind.1 = 1
Wait 1
Pind.1 = 0
Wait 1
If Pinc.3 = 0 Then Goto L1
Loop


L2:
Cls
Locate 1 , 4
Lcd ".::key::."
 

boxochi

کاربر vip
vip
کاربر
2010-10-02
61
110
سلام به جای PIN از PORT استفاده کن برا ست کردن خروجی
کد:
$regfile = "m8def.dat"
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
Config Portc = Input
Config Portd = Output
Cursor Off
Cls
Do
Locate 1 , 3
Lcd ".::Menu::."


Locate 2 , 1
Lcd "1.LED"


Locate 2 , 11
Lcd "2.key"


If Pinc.1 = 1 Then Goto L1
If Pinc.2 = 1 Then Goto L2
Loop


L1:
Cls
Do
Locate 1 , 4
Lcd ".::LED::."


Locate 2 , 1
Lcd "1.ON"


Locate 2 , 6
Lcd "2.OFF"


Locate 2 , 12
Lcd "3.BK"


If Pinc.1 = 1 Then PORTD.1 = 1


If Pinc.2 = 1 Then Portd.1 = 0


If Pinc.3 = 1 Then Goto L5
Loop


L5:
Do
Portd.1 = 1
Wait 1
Portd.1 = 0
Wait 1
If Pinc.3 = 0 Then Goto L1
Loop


L2:
Cls
Locate 1 , 4
Lcd ".::key::."
End
 

پیوست‌ها

  • 18.4 کیلوبایت بازدیدها: 21

dr.mohammad

کاربر
2014-12-02
31
17
سلام به جای PIN از PORT استفاده کن برا ست کردن خروجی
کد:
$regfile = "m8def.dat"
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
Config Portc = Input
Config Portd = Output
Cursor Off
Cls
Do
Locate 1 , 3
Lcd ".::Menu::."


Locate 2 , 1
Lcd "1.LED"


Locate 2 , 11
Lcd "2.key"


If Pinc.1 = 1 Then Goto L1
If Pinc.2 = 1 Then Goto L2
Loop


L1:
Cls
Do
Locate 1 , 4
Lcd ".::LED::."


Locate 2 , 1
Lcd "1.ON"


Locate 2 , 6
Lcd "2.OFF"


Locate 2 , 12
Lcd "3.BK"


If Pinc.1 = 1 Then PORTD.1 = 1


If Pinc.2 = 1 Then Portd.1 = 0


If Pinc.3 = 1 Then Goto L5
Loop


L5:
Do
Portd.1 = 1
Wait 1
Portd.1 = 0
Wait 1
If Pinc.3 = 0 Then Goto L1
Loop


L2:
Cls
Locate 1 , 4
Lcd ".::key::."
End
مرسی حل شد .
 
بالا