You are on page 1of 9

program LCD_button dim LCD_RS LCD_EN LCD_D7 LCD_D6 LCD_D5 LCD_D4 as as as as as as sbit sbit sbit sbit sbit sbit

at at at at at at RB4_bit RB5_bit RB3_bit RB2_bit RB1_bit RB0_bit at at at at at at TRISB4_bit TRISB5_bit TRISB3_bit TRISB2_bit TRISB1_bit TRISB0_bit

dim LCD_RS_Direction as sbit LCD_EN_Direction as sbit LCD_D7_Direction as sbit LCD_D6_Direction as sbit LCD_D5_Direction as sbit LCD_D4_Direction as sbit dim cnt, a as integer

main: trisa= 255 portb=0 cnt=17 a=17 Lcd_Init() Lcd_cmd(_LCD_CLEAR) Lcd_cmd(_LCD_CURSOR_OFF) loop_a: if (porta.1)=0 then Lcd_cmd(_LCD_CLEAR) Lcd_Out(2,cnt,"-_-_-_-_-_-_-_-_") delay_ms(100) cnt= cnt-1 goto loop_a if cnt<-16 then end if end if b: if (porta and 1)=0 then Lcd_cmd(_LCD_CLEAR) Lcd_Out(2,a,"-_-_HELLO-_-_-_-") delay_ms(100) a = a -1 goto b if a< -16 then end if end if goto main

end.

program _buttonservo4 ' Declarations section main: trisb=%00000000 portb= 0 trisa= 255 goto main if porta.0= 0 then portb.0= 1 delay_us(1000) porta.0=0 delay_us(15) end if if porta.1=0 then portb.0=1 delay_us(1250) porta.0=0 delay_us(15) end if if porta.2= 0 then portb.0 =1 delay_us(1500) porta.0=0 delay_us(15) end if if porta.3= 0 then portb.0 =1 delay_us(1750) porta.0=0 delay_us(15) end if if porta.4 =0 then portb.0= 1 delay_us(2000) porta.0=0 delay_us(15) end if goto main end.

program _buttonservo ' Declarations section main: trisb=%00000000 portb= 0 trisa= 255 loop_a: if porta.0= 0 then portb.0= 1 delay_us(2000) portb.0= 0 delay_us(15) else goto loop_b end if goto loop_a loop_b: portb.0=1 delay_us(15) portb.0=0 delay_us(2000) goto main end.

program _buttonservo3 ' Declarations section main: trisb=%00000000 portb= 0 trisa= 255

if porta.0= 0 then portb.0= 1 delay_us(999) porta.0=0 delay_us(15) portb.1=1 delay_us(1999) porta.1=0 delay_us(15) end if if porta.1=0 then portb.0=1 delay_us(1249) porta.0=0 delay_us(15) portb.1=1 delay_us(1749) porta.1=0 delay_us(15) end if if porta.2= 0 then portb.0 =1 delay_us(1499) porta.0=0 delay_us(15) portb.1=1 delay_us(1499) porta.1=0 delay_us(15) end if if porta.3= 0 then portb.0 =1 delay_us(1749) porta.0=0 delay_us(15) portb.1=1 delay_us(1249) porta.1=0 delay_us(15) end if if porta.4 =0 then portb.0= 1 delay_us(1999) porta.0=0 delay_us(15) portb.1=1 delay_us(999) porta.1=0 delay_us(15) end if goto main

end.

program motor ' Declarations section main: cmcon= 7 trisa.0=1 trisb= 0 portb= 0 loop_a: delay_us(900) if porta.0=0 then portb.0 = 1 portb.1= 0 else portb.0=0 portb.1=1 end if delay_us(100)

goto loop_a end. program Stepper_2 ' Declarations section dim cnt as integer main: trisb= 0 portb=0 cnt= 1 trisa= 255 cmcon=7 loop_a: portb= %00000010 select case cnt case 1 portb =%00000010 case 2 portb =%00000001 case 3 portb =%00001000

case 4 portb =%00000100 case else portb=0 end select if porta.0 =0 then cnt=cnt + 1 if cnt> 4 then cnt= 1 end if else cnt= cnt-1 if cnt < 1 then cnt= 4 end if end if delay_ms(100) goto loop_a end.

program Stepper_2 ' Declarations section dim cnt as integer main: trisb= 0 portb=0 cnt= 1 trisa= 255 cmcon=7 loop_a: portb= %00000010 select case cnt case 1 portb =%00000010 case 2 portb =%00000001 case 3

portb =%00001000 case 4 portb =%00000100 case else portb=0 end select if porta.0 =0 then cnt=cnt + 1 if cnt> 4 then cnt= 1 end if else cnt= cnt-1 if cnt < 1 then cnt= 4 end if end if delay_ms(100) goto loop_a end.

program Stepper ' Declarations section main: trisb= 0 portb= 0 loop_a: portb= %00001000 delay_ms(50) portb= %00000100 delay_ms(50) portb= %00000010 delay_ms(50) portb= %00000001 delay_ms(50)

goto loop_a end.

program stepper22 ' Declarations section dim cnt as integer main: ' Main program trisb= 0 portb= 0 cnt= 1 trisa= 255 cmcon= 7 loop_a:

select case cnt case 1 portb =%00000010 case 2 portb =%00000001 case 3 portb =%00001000 case 4 portb =%00000100 case else portb=0 end select if porta.0 =0 then cnt=cnt + 1 if cnt> 4 then cnt= 1 end if end if if porta.1 = 0 then cnt= cnt-1 if cnt < 1 then cnt= 4 end if end if delay_ms(100)

goto loop_a end.

You might also like