Shop OBEX P1 Docs P2 Docs Learn Events
7 Segmentns and hc595 — Parallax Forums

7 Segmentns and hc595

The_ApprenticeThe_Apprentice Posts: 15
edited 2006-04-15 09:12 in Learn with BlocklyProp
HI, can some body give a tip in how to display numbers on the 7 segments, i'm running this code, the pattern change segment by segment in order, I try to modify the patter to see if I can get some numbers, but i coudn't. Please if any body can help me i will really appreciate.


INCLUDE "modedefs.bas"
Clock CON 0 ' shift clock (74HC595.11)
DataOut CON 1 ' serial data out (74HC595.14)
Latch CON 2 ' output latch (74HC595.12)
DelayTime CON 100
pattern VAR Byte ' output pattern
Initialize:
LOW Latch ' make output and keep low
pattern = %00000001
Go_Forward:
GOSUB Out_595
PAUSE DelayTime ' put pattern on 74x595
pattern = pattern << 1 ' shift pattern to the left
IF (pattern = %10000000) THEN Go_Reverse ' test for final position
GOTO Go_Forward ' continue in this direction
Go_Reverse:
GOSUB Out_595
PAUSE DelayTime
pattern = pattern >> 1
IF (pattern = %00000001) THEN Go_Forward
GOTO Go_Reverse
Out_595:
SHIFTOUT DataOut, Clock, MSBFirst, [noparse][[/noparse]pattern] ' send pattern to 74x595
PULSOUT Latch, 5 ' latch outputs
RETURN

Comments

  • SSteveSSteve Posts: 808
    edited 2006-04-15 09:12
    You just need to send a pattern that makes a number. I copied these from the StampWorks manual:

    Digit0 DATA %00111111
    Digit1 DATA %00000110
    Digit2 DATA %01011011
    Digit3 DATA %01001111
    Digit4 DATA %01100110
    Digit5 DATA %01101101
    Digit6 DATA %01111101
    Digit7 DATA %00000111
    Digit8 DATA %01111111
    Digit9 DATA %01100111
    



    This should display the digits 0 to 9.
    Main:
      FOR idx=0 TO 9
        READ Digit0 + idx, pattern
        GOSUB Out_595
        PAUSE 500
      NEXT
    GOTO Main
    



    I haven't tested this and it's two in the morning so there could be errors but hopefully it will get you going.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
Sign In or Register to comment.