Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7729445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:58:09+00:00 2026-06-01T05:58:09+00:00

I’m trying to do something like this . The problem is that i can’t

  • 0

I’m trying to do something like this.
The problem is that i can’t build the loop that does that.
Circuit:

Here is my code:

import parallel 
import time
p=parallel.Parallel() #object to use the parallel port
print ("Enter a string of numbers: ")
numStr = raw_input() #read line
numList=list(numSTr) #converts string to list
numlen=len(numList) #the length of the list
numBin=[['1','0001'], ['2','0010'],
 ['4','0100'], ['5','0101'],
 ['6','0110'], ['7','0111'],
 ['8','1000'], ['9','1001'],
 ['3','0011'], ['0','0000']] #Less significant bits of the numbers from 0 to 9 in a bidimesional array
p.setData(0) #clear the displays
pos=['0001','0010','0100','1000'] #Unique possible positions for the number from 0 to 9. 
c=(str(pos[])+str((numBin[][1]))) #here if the number in the list numList exist and also is in numBin. It joins the position and the number in binary, creating an number that will be send in decimal to the parallel port.
p.setData(int(c,2)) #send the binary number in decimal

If someone can help me, that would be gratifying

The most significant bits that are in numBin, define what display to turn on. And the less significant define the number.
For example:

The string is {‘7’, ‘1’, ‘5’, ‘4’, ‘8’}.
So the first number to show in the last display is ‘7’. SO we take the binary 7 that is ‘0111’ and join that binary string with the first display position that is ‘0001’. SO we create a binary number: ‘00010111’. We conver that number to decimal and send it to the parallel port. The parallel port turns on the las display and shows the number 7.
The second time, it must show a ‘7’ and a ‘1’ in the second and fist position and so.

X X X X
X X X 7
X X 7 1
X 7 1 5
7 1 5 4
1 5 4 8
5 4 8 X
4 8 X X
8 X X X
X X X X

The ‘X’ represents that the display is off and the number represents itself in the display position as you can see in the circuit.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:58:11+00:00Added an answer on June 1, 2026 at 5:58 am

    Looking at your circuit, you can’t actually display different numbers simultaneously. I had a circuit like this on a demo FPGA board, and had to create a software driver to flicker the numbers on the display in the correct positions at a speed faster than the eye could detect.

    Below is a a rough algorithm, using a Mock object to simulate the parallel port and the display for my testing. It must be run on a terminal that supports carriage return without linefeed.

    You should be able to drop in your parallel library instead, but may have to adjust the control bits to match your hardware:

    import sys
    
    class ParallelMock(object):
    
        def __init__(self):
            '''Init and blank the "display".'''
            self.display = [' '] * 4
            self._update()
    
        def setData(self,data):
            '''Bits 0-3 are the "value".
               Bits 4-7 are positions 0-3 (first-to-last).
            '''
            self.display = [' '] * 4
            value = data & 0xF
            if data & 0x10:
                self.display[0] = str(value)
            if data & 0x20:
                self.display[1] = str(value)
            if data & 0x40:
                self.display[2] = str(value)
            if data & 0x80:
                self.display[3] = str(value)
            self._update()
    
        def _update(self):
            '''Write over the same four terminal positions each time.'''
            sys.stdout.write(''.join(self.display) + '\r')
    
    if __name__ == '__main__':
        p = ParallelMock()
    
        nums = raw_input("Enter a string of numbers: ")
    
        # Shift over the steam four-at-a-time.
        stream = 'XXXX' + nums + 'XXXX'
        data = [0] * 4
        for i in range(len(stream)-3):
            # Precompute data
            for pos in range(4):
                value = stream[i+pos]
                data[pos] = 0 if value == 'X' else (1<<(pos+4)) + int(value)
            # "Flicker" the display...
            for delay in xrange(1000):
                # Display each position briefly.
                for d in data:
                    p.setData(d)
            # Clear the display when done
            p.setData(0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.