Help lcd issue 3 pin lcd
thomas.saddler
Posts: 2
hi need help my code works on the BS2 but as soon as i load into the BS2sx the lcd does crazy stuff. help me please. here is my code.
' -----[ Title ]----------------------------------------------------------- ' Sonic Looper ' {$STAMP BS2} ' {$PBASIC 2.5} ' {$PORT COM10} ' -----[ Variables ]------------------------------------------------------- time VAR Word ' Round trip echo time LooperCnt VAR Byte ' Count of Loops counter VAR Word ' Counter for FOR...NEXT loop ' -----[ Constants ]------------------------------------------------------- maxDist CON 4000 ' Maximum distance for alarm trigger ' -----[ Jolly Roger Custom Characters ]----------------------------------- SEROUT 8, 84, [248, 000, 000, 000, 100, ' Top left 110, 011, 001, 000] ' crossbone SEROUT 8, 84, [249, 000, 001, 011, 110, ' Bottom left 100, 000, 000, 000] ' crossbone SEROUT 8, 84, [250, 000, 110, 111, 111, ' Top half 101, 101, 111, 110] ' of skull SEROUT 8, 84, [251, 110, 111, 111, 001, ' Bottom half 001, 111, 110, 000] ' of skull SEROUT 8, 84, [252, 000, 011, 011, 110, ' Top right 110, 011, 011, 000] ' crossbone SEROUT 8, 84, [253, 000, 011, 011, 110, ' Bottom right 110, 011, 011, 000] ' crossbone ' -----[ Initialization ]-------------------------------------------------- SEROUT 8, 84, [22,12] ' Initialize LCD PAUSE 5 LooperCnt = 0 ' Reset Looper count to 0 ' -----[ Main Routine ]---------------------------------------------------- DO HIGH 4 ' Flash LEDs PULSOUT 15, 5 ' Send pulse PULSIN 15, 1, time ' Read echo time IF (time < maxDist) THEN ' If Looper is triggered... LooperCnt = LooperCnt + 1 SEROUT 8, 84, [128, 0, 129, 2, 130, 4, ' Display Jolly Roger 148, 1, 149, 3, 150, 5] SEROUT 8, 84, [132, DEC LooperCnt, ' Display number of alarm " Material "] ' triggers on the LCD SEROUT 8, 84, [153, "Detected!! "] FOR counter = 0 TO 0 HIGH 13 ' Flash LEDs HIGH 12 PAUSE 600 LOW 13 ' Flash LEDs LOW 12 NEXT ELSEIF (LooperCnt = 0) THEN SEROUT 8, 84, [128, 0, 129, 2, 130, 4, ' Display Jolly Roger 148, 1, 149, 3, 150, 5] SEROUT 8, 84, [133, "Looper", 153, "On!"] SEROUT 8, 84, [141, 0, 142, 2, 143, 4, ' Display Jolly Roger 161, 1, 162, 3, 163, 5] ENDIF PAUSE 100 LOOP
Comments
Change the 84 to 240 or use code like this to handle various models