پاسخ : کمک برای ساخت ماژول سریال LCD های کاراکتری
مرسی دوست خوبم.تست میکنم خبرشو میدم
مرسی دوست خوبم.تست میکنم خبرشو میدم
Include "modedefs.bas" ' Include serial modes
Trisa = %00000000 ' set porta to outputs
Trisb = %00001000 ' set portb pin 3 to input
Lcd Var Porta.3 ' define variables and constants
Piezo Var Portb.4
Trigger Var Portb.2
Echo Var Portb.3
Left_led Var Portb.0
Right_led Var Portb.1
Baud Con T9600
Dist_raw Var Word
Dist_inch Var Word
Dist_cm Var Word
Conv_inch Con 15
Conv_cm Con 6
Low Trigger ' set trigger pin to logic 0
Low Left_led ' turn off left LED
Low Right_led ' turn off right LED
Serout Lcd , Baud , [254 , 1] ' clear lcd screen
Pause 100 ' give time to initialize lcd
Serout Lcd , Baud , [254 , 128 , "- Sonar Ranger -"] ' display program title on the LCD
Sound Piezo , [100 , 10 , 50 , 5 , 70 , 10 , 50 , 2] ' Make startup sound
Pause 100 ' wait for 1 second
Serout Lcd , Baud , [254 , 128 , "inches: "] ' set up the LCD display
Serout Lcd , Baud , [254 , 192 , "centimeters: "]
Main:
Gosub Sr_sonar ' get sonar reading
Serout Lcd , Baud , [241 , 0 , #dist_inch , 242] ' display the distance in inches
Serout Lcd , Baud , [241 , 1 , #dist_cm , 242] ' display the distance in centimeters
Goto Main
End
Sr_sonar:
Pulsout Trigger , 1 ' send a 10us trigger pulse to the SRF04
Pulsin Echo , 1 , Dist_raw ' start timing the pulse width on echo pin
Dist_inch =(dist_raw / Conv_inch) ' Convert raw data into inches
Dist_cm =(dist_raw / Conv_cm) ' Convert raw data into centimeters
Pause 1 ' wait for 10us before returning to main
Return
Include "modedefs.bas" ' Include serial modes
Trisa = %00000000 ' set porta to outputs
Trisb = %00001000 ' set portb pin 3 to input
Lcd Var Porta.3 ' define variables and constants
Piezo Var Portb.4
Trigger Var Portb.2
Echo Var Portb.3
Left_led Var Portb.0
Right_led Var Portb.1
Baud Con T9600
Dist_raw Var Word
Dist_inch Var Word
Dist_cm Var Word
Conv_inch Con 15
Conv_cm Con 6
Low Trigger ' set trigger pin to logic 0
Low Left_led ' turn off left LED
Low Right_led ' turn off right LED
Serout Lcd , Baud , [241 , 12 , 242] ' clear lcd screen
Pause 100 ' give time to initialize lcd
Serout Lcd , Baud , [241 , 0, "- Sonar Ranger -",242] ' display program title on the LCD
Sound Piezo , [100 , 10 , 50 , 5 , 70 , 10 , 50 , 2] ' Make startup sound
Pause 100 ' wait for 1 second
Serout Lcd , Baud , [241 , 0, "inches: " ,242] ' set up the LCD display
Pause 50
Serout Lcd , Baud , [241 , 1, "centimeters: " ,242]
Pause 1000
Main:
Gosub Sr_sonar ' get sonar reading
Pause 20
Serout Lcd , Baud , [241 ,128 , #dist_inch , 242] ' display the distance in inches
Pause 20
Serout Lcd , Baud , [241 , 209 , #dist_cm , 242] ' display the distance in centimeters
Goto Main
End
Sr_sonar:
Pulsout Trigger , 1 ' send a 10us trigger pulse to the SRF04
Pulsin Echo , 1 , Dist_raw ' start timing the pulse width on echo pin
Dist_inch =(dist_raw / Conv_inch) ' Convert raw data into inches
Dist_cm =(dist_raw / Conv_cm) ' Convert raw data into centimeters
Pause 1 ' wait for 10us before returning to main
Return
RS - PORTB Bit 0 RD - PORTB Bit 1 EN - PORTB Bit 2 D4 - PORTC Bit 0 D5 - PORTC Bit 1 D6 - PORTC Bit 2 D7 - PORTC Bit 3



دیدگاه