Shop OBEX P1 Docs P2 Docs Learn Events
Programming 1 digit 7 segment display help. — Parallax Forums

Programming 1 digit 7 segment display help.

CoolNerd27CoolNerd27 Posts: 6
edited 2012-06-23 23:00 in BASIC Stamp
So i'm writing a program with the basic stamp 2 that gets a number from a remote, then plays the morse code for that number while displaying the number on a 7 segment display. right now the program has about 150 lines that are telling the stamp how to display the numbers using the HIGH and LOW commands. is there any way i can shorten it. here is the part of the program. tr, br, tl, bl, top, bot, mid stand for what part of the display it's controlling. Help.
one:
GOSUB clear
HIGH tr
HIGH br
RETURN
two:
GOSUB clear
HIGH top
HIGH tr
HIGH mid
HIGH bl
HIGH bot
RETURN
three:
GOSUB clear
HIGH top
HIGH tr
HIGH br
HIGH mid
HIGH bot
RETURN
ect......
clear:
LOW top
LOW mid
LOW bot
LOW br
LOW bl
LOW tr
LOW tl

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-06-23 22:10
    If you attach your 7-Seg display to a group of 8 I/O pins (7 segments plus decimal point), you can set all 8 pins at once to a single 8-bit value. The two 8-bit groups are OUTL (pins 0-7) and OUTH (pins 8-15). You'd use statements like "OUTH = %10110110".
  • CoolNerd27CoolNerd27 Posts: 6
    edited 2012-06-23 23:00
    Thanks that saved me a lot of time and space.
Sign In or Register to comment.