哦 还有个液晶屏 总成本 不超过50吧,液晶屏 是不带背光的 花了8块买的 程序 很长啊 有耐心读吗 BASIC和ASM的混合语言编写的,下面的只是主驱动程序,车背面的程序还没写好。 zuojixian var byte youjixian var byte lhs var byte scs var byte lhc var byte zxs var byte sc0 var byte zxc var byte sc1 var byte r1b var byte r2b var byte r3b var byte r4b var byte r1c var byte r2c var byte r3c var byte r4c var byte asm zxc equ 049h zxs equ 04ah zuojixian equ 48h youjixian equ 47h lhc equ 03ah lhs equ 03bh sc0 equ 044h sc1 equ 045h scs equ 046h #define status 03h #define porta 05h #define portb 06h #define portc 07h #define portd 08h #define porte 09h #define trisa 85h #define trisb 86h #define trisc 87h #define trisd 88h #define trise 89h #define option_reg 81h endasm start: asm bsf status,0 banksel trisd movlw 00h movwf trisd movlw 0ffh movwf trisb bcf trisb,4 banksel portd movlw 00h movwf portd bcf portb,4 endasm pause 500 @bsf portb,4 zuojixian=43 youjixian=110 r1c=2 r2c=4 r3c=4 r4c=4 main: @clrwdt pot portc.0,232,lhs pot portc.1,235,scs pot portc.2,120,lhc pot portc.3,100,zxs pot portc.4,160,sc0 pot portc.5,120,zxc pot portc.6,255,sc1 sc0=sc0+10 sc1=sc1-2 lhs=lhs+15 Lcdout $fe, 1 lcdout #zxs lcdout 254,131 lcdout ";" Lcdout #lhs lcdout 254,135 lcdout ";" lcdout #scs lcdout 254,139 lcdout ";" lcdout 254, 192 LCDOUT #zxc lcdout 254,195 LCDOUT ";" lcdout #lhc lcdout 254,199 LCDOUT ";" LCDOUT #sc0 lcdout 254,203 lcdout ";" LCDOUT #sc1 LCDOUT ";" if zxs<=zuojixian then zxs=zuojixian endif if zxs>=youjixian then zxs=youjixian endif r1b=zxs-zxc r1b=abs r1b r2b=lhs-lhc r2b=abs r2b r3b=scs-sc0 r3b=abs r3b r4b=scs-sc1 r4b=abs r4b @b1: if r1b>r1c then goto zx else goto buzhuanxiang endif @b2: if r2b>r2c then goto lhxianzhi else goto budong endif @b3: if r3b>r3c then goto sc0xianzhi else goto stop0 endif @b4: if r4b>r4c then goto sc1xianzhi else goto stop1 endif @b5: goto main zx: asm bsf status,0 movf zxc,0 subwf zxs,0 btfsc status,0 goto youzhuan goto zuozhuan youzhuan bsf portd,0 bcf portd,1 bsf status,0 goto b2 zuozhuan bcf portd,0 bsf portd,1 bsf status,0 goto b2 endasm buzhuanxiang: asm bcf portd,0 bcf portd,1 bsf status,0 goto b2 endasm lhxianzhi: if lhc<=80 then goto hexianwei endif if lhc>80 then goto lixianwei endif hexianwei: asm btfss portb,5 goto lima goto lh lima bsf status,0 movf lhc,0 subwf lhs,0 btfss status,0 goto budong goto li budong bcf portd,2 bcf portd,3 bsf status,0 goto b3 endasm lixianwei: asm btfss portb,5 goto hema goto lh hema bsf status,0 movf lhc,0 subwf lhs,0 btfsc status,0 goto budong goto he lh bsf status,0 movf lhc,0 subwf lhs,0 btfss status,0 goto he goto li he bsf portd,2 bcf portd,3 bsf status,0 goto b3 li bcf portd,2 bsf portd,3 bsf status,0 goto b3 endasm budong: asm bcf portd,2 bcf portd,3 bsf status,0 goto b3 endasm sc0xianzhi: if sc0<=80 then goto sha0xianzhi endif if sc0>80 then goto song0xianzhi endif sha0xianzhi: asm btfss portb,6 goto songma0 goto shache0 songma0 bsf status,0 movf sc0,0 subwf scs,0 btfss status,0 goto stop0 goto shache0 endasm song0xianzhi: asm btfss portb,6 goto shama0 goto shache0 shama0 bsf status,0 movf sc0,0 subwf scs,0 btfss status,0 goto shache0 goto stop0 shache0 bsf status,0 movf sc0,0 subwf scs,0 btfsc status,0 goto song0 goto sha0 song0 bsf portd,4 bcf portd,5 bsf status,0 goto b4 sha0 bcf portd,4 bsf portd,5 bsf status,0 goto b4 stop0 bcf portd,4 bcf portd,5 bsf status,0 goto b4 endasm stop0: asm bcf portd,4 bcf portd,5 bsf status,0 goto b4 endasm sc1xianzhi: if sc1<=80 then goto sha1xianzhi endif if sc1>80 then goto song1xianzhi endif sha1xianzhi: asm btfss portb,7 goto songma1 goto shache1 songma1 bsf status,0 movf sc1,0 subwf scs,0 btfss status,0 goto stop1 goto shache1 endasm song1xianzhi: asm btfss portb,7 goto shama1 goto shache1 shama1 bsf status,0 movf sc1,0 subwf scs,0 btfss status,0 goto shache1 goto stop1 shache1 bsf status,0 movf sc1,0 subwf scs,0 btfsc status,0 goto song1 goto sha1 song1 bsf portd,6 bcf portd,7 bsf status,0 goto b5 sha1 bcf portd,6 bsf portd,7 bsf status,0 goto b5 stop1 bcf portd,6 bcf portd,7 bsf status,0 goto b5 endasm stop1: asm bcf portd,6 bcf portd,7 bsf status,0 goto b5 endasm |
广告投放|联系我们|手机|投稿|Archiver|About us|Advertise|遥控迷模型网|RCFans ( 粤ICP备10210518号-1 )
版权所有 RCFans.com © 2003-2016