Devre pic16f84 ile yapılmış 8 led kontrol edilebiliyor 4 mod efekt bulunuyor komitatör ya da kademeli anahtar ile seçim yapılabilir kaynak proton kodları ve proteus isis simülasyon dosyası var
isis devre şeması;
proton kodları;
'**************************************************************** '* Name : Running-LEDs.BAS * '* Author : F.San * '* Date : 11.01.2004 * '**************************************************************** @ device pic16F84, xt_osc, wdt_off, pwrt_on, protect_off ' PortB Leds LD1 Con 1 LD2 Con 2 LD3 Con 4 LD4 Con 8 LD5 Con 16 LD6 Con 32 LD7 Con 64 LD8 Con 128 PB_Up var PortA.0 PB_Dn var PortA.1 PB_Auto var PortA.2 Up_Dn var bit Mode var byte ModeOld var byte PBData var byte Cnt1 var byte Cnt2 var word TrisA = %11111 TrisB = %00000000 PortA = 0 PortB = 0 modeOld = 0 Up_Dn = 1 ' Count up Cnt1 = 0 Main: Mode = PortA >> 3 ' Read Mode Switch if modeOld <> Mode then ' if mode switch changed then, Modeold = Mode ' Save new mode and PBData = 0 ' Clear PortB leds Up_Dn = 1 ' Count up Cnt1 = 0 endif gosub Chk_PB_UpDn if PB_Auto then if Up_Dn = 1 then gosub Run_Up else gosub Run_Dn endif endif PortB = PBData if PB_Auto then pause 100 else gosub DeBounce endif Goto Main Chk_PB_UpDn: if PB_Up then Up_Dn = 1 if not PB_Auto then gosub Run_Up else if PB_Dn then Up_Dn = 0 if not PB_Auto then gosub Run_Dn endif endif return Run_Up: select case Mode case 0 if Cnt1 = 16 then if PB_Auto then Up_Dn = 0 else cnt1 = 0 endif endif Cnt1 = cnt1 + 1 gosub Mode0 case 1 if Cnt1 = 9 then if PB_Auto then Up_Dn = 0 else cnt1 = 0 endif endif Cnt1 = cnt1 + 1 gosub Mode1 case 2 PBData = PBData + 1 case 3 if Cnt1 = 11 then if PB_Auto then Up_Dn = 0 else cnt1 = 0 endif endif Cnt1 = cnt1 + 1 gosub Mode3 end select return Run_Dn: select case Mode case 0 if Cnt1 = 0 then if PB_Auto then Up_Dn = 1 else cnt1 = 16 endif endif Cnt1 = cnt1 - 1 gosub Mode0 case 1 if Cnt1 = 0 then if PB_Auto then Up_Dn = 1 else cnt1 = 9 endif endif Cnt1 = cnt1 - 1 gosub Mode1 case 2 PBData = PBData - 1 case 3 if Cnt1 = 0 then if PB_Auto then Up_Dn = 1 else cnt1 = 11 endif endif Cnt1 = cnt1 - 1 gosub Mode3 end select return Mode0: select case cnt1 case 00 : PBData = 0 case 01 : PBData = ld1 case 02 : PBData = ld1+ld2 case 03 : PBData = ld1+ld2+ld3 case 04 : PBData = ld1+ld2+ld3+ld4 case 05 : PBData = ld1+ld2+ld3+ld4+ld5 case 06 : PBData = ld1+ld2+ld3+ld4+ld5+ld6 case 07 : PBData = ld1+ld2+ld3+ld4+ld5+ld6+ld7 case 08 : PBData = ld1+ld2+ld3+ld4+ld5+ld6+ld7+ld8 case 09 : PBData = ld2+ld3+ld4+ld5+ld6+ld7+ld8 case 10 : PBData = ld3+ld4+ld5+ld6+ld7+ld8 case 11 : PBData = ld4+ld5+ld6+ld7+ld8 case 12 : PBData = ld5+ld6+ld7+ld8 case 13 : PBData = ld6+ld7+ld8 case 14 : PBData = ld7+ld8 case 15 : PBData = ld8 case 16 : PBData = 0 end select return Mode1: select case cnt1 case 00 : PBData = 0 case 01 : PBData = ld1 case 02 : PBData = ld2 case 03 : PBData = ld3 case 04 : PBData = ld4 case 05 : PBData = ld5 case 06 : PBData = ld6 case 07 : PBData = ld7 case 08 : PBData = ld8 case 09 : PBData = 0 end select return Mode3: select case cnt1 case 00 : PBData = 0 case 01 : PBData = ld1 case 02 : PBData = ld1+ld2 case 03 : PBData = ld1+ld2+ld3 case 04 : PBData = ld2+ld3+ld4 case 05 : PBData = ld3+ld4+ld5 case 06 : PBData = ld4+ld5+ld6 case 07 : PBData = ld5+ld6+ld7 case 08 : PBData = ld6+ld7+ld8 case 09 : PBData = ld7+ld8 case 10 : PBData = ld8 case 11 : PBData = 0 end select return DeBounce: Cnt2 = 0 repeat Cnt2 = Cnt2 + 1 pause 1 until (PB_Dn = 0) and (PB_Up = 0) or (Cnt2 > 200) if Cnt2 < 50 then pause (50 - Cnt2) ' debounce return End
pic16f84-ile-8-led-sov-4-mod-proton-proteus-isis
Şifre-Pass: 320volt.com
Yayım tarihi: 2010/02/16 Etiketler: led animasyon, led efekt, led oyun, led şov, microchip pic projeleri, PIC16F84 örnekleri, proton