depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

controlling 4-digit display with gpiozero

Wed Sep 28, 2016 4:24 pm

Hello,

I'm making an project (display unread emails), where I'd like to control a 4 digit segment display. This time I'd like to use Gpiozero!!!

The foundation's Essentials guide on Gpiozero gave me an example code to control a 1 digit display.
Now I'm trying to transform the code from a 4 digit display, using 'normal' Gpio into code for GpioZero
I've commented out the sections that come from the 'normal' gpio code.
I'm learning by try and error....
and I'm completely stuck.....

Here is the code:

Code: Select all

#transform from gpio to gpiozero

from gpiozero import LED
import time

seg = [LED(8,active_high=False),LED(18,active_high=False),LED(10,active_high=False),
      LED(9,active_high=False),LED(11,active_high=False),LED(25,active_high=False),
      LED(22,active_high=False)]
segmentPattern = [[0,1,2,3,4,6],[1,2],[0,1,5,4,3],[0,1,2,3,5],[1,2,5,6],[0,2,3,5,6], #0 to 5
                 [0,2,3,4,5,6],[0,1,2],[0,1,2,3,4,5,6],[0,1,2,5,6],[0,1,2,4,5,6] ] #6 to 9


#GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
#segments = (24,12,19,21,23,22,15)

#for segment in segments:
 #   GPIO.setup(segment, GPIO.OUT)
  #  GPIO.output(segment, 0)

digits = [LED(7,active_high=True),LED(24,active_high=True),LED(23,active_high=True),
         LED(17,active_high=True)]          

#digits = (7,24,23,27)

#for digit in digits:
 #   GPIO.setup(digit, GPIO.OUT)
  #  GPIO.output(digit, 1)

#num = {' ':(0,0,0,0,0,0,0),
#    '0':(1,1,1,1,1,1,0),
#    '1':(0,1,1,0,0,0,0),
#    '2':(1,1,0,1,1,0,1),
#    '3':(1,1,1,1,0,0,1),
#    '4':(0,1,1,0,0,1,1),
#    '5':(1,0,1,1,0,1,1),
#    '6':(1,0,1,1,1,1,1),
#    '7':(1,1,1,0,0,0,0),
#    '8':(1,1,1,1,1,1,1),
#    '9':(1,1,1,1,0,1,1),
#    'H':(0,1,1,0,1,1,1),
#    'I':(0,1,1,0,0,0,0),
#    'G':(1,0,1,1,1,1,0)
#       }


try:

    while True:

        n = 9999 #number or value of a variable. 
        print (n)

        if n > 9999:
            number = 'HIGH'
        else:
            number = str(n).rjust(4)

        for digit in range(4):
            for i in range(0,7):
                seg[i].on()
                for i in range(0,len(segmentPattern[number])):
                     seg[segmentPattern[number][i]].off()

                #GPIO.output(segments[loop], num[s[digit]][loop]) 
           # GPIO.output(digits[digit], 0)
           # time.sleep(0.001)
           # GPIO.output(digits[digit], 1)
            

except KeyboardInterrupt:
    GPIO.cleanup()
This code gives me this error:
Traceback (most recent call last):
File "zero4.py", line 63, in <module>
for i in range(0,len(segmentPattern[number])):
TypeError: list indices must be integers, not str


But as you can see, I'm just trying and guessing. I don't even know exactly what I'm doing :?

I hope someone can help me? Put me in the right direction?
All help is very much appreciated!!!

Kind regards,
Christophe
Last edited by depauw on Sat Oct 01, 2016 4:14 pm, edited 1 time in total.

User avatar
scruss
Posts: 2548
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: controlling 4-digit display with gpiozero

Wed Sep 28, 2016 7:12 pm

you've commented out the 'num' dictionary/hash and you're trying to use a one character string as the index of the array 'segmentpattern' (or however you've capsed it).

If you want to have spaces and the letters H, I ad G usable, you have to use the dictionary. Otherwise, make sure you're only talking single-digit numbers
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 8:58 am

Disabeling the uncommenting of the dictionary: that I can :)

But bringing it to a 4 character string.... is out of my league :?:

Or does anyone have a working example for such a kind of 4 digit display?

User avatar
scruss
Posts: 2548
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 12:20 pm

It looks like a lot of your code was cribbed from this thread Controlling a 7 segment 4 digit display with a Raspberry Pi, so you might want to ask there. There are also working examples.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 2:27 pm

That is indeed my inspirational source of the code using gpio.
But now, i want to get it working using zerogpio!

User avatar
B.Goode
Posts: 8864
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 2:39 pm

This publication from MagPi has a section that deals with 7 segment Led displays: https://www.raspberrypi.org/magpi/gpio-zero-essentials/

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 3:11 pm

Indeed! and I have this one working. But it is for a 1digit display. I'd like to use a 4digit display and I don't know how to do that.....

User avatar
B.Goode
Posts: 8864
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 3:18 pm

I can see now that you started by saying that! Apologies!

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 3:39 pm

No problem!
It's just a bit frustrating :(
I think it all comes down to about 5 lines of code, that I can't write myself because I don't have the knowledge.

scotty101
Posts: 3735
Joined: Fri Jun 08, 2012 6:03 pm

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 4:03 pm

Break down the problem in to little steps and I'm sure we can help you work the problem.

I'd guess the first thing you need to do is to split a 4 digit number in to it's separate digits. This can be done in one line of python code (and the additional two lines to set the number and print it)

Code: Select all

num = 1234
digits = [int(x) for x in str(num)]
print(digits)
This can be extended if you want to pad out the first digits with leading zeros.

Code: Select all

digits = [int(x) for x in str(num).zfill(4)]
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 4:32 pm

Ok!

Did some code-cleaning an introduced the proposed code.
We're already one step futher!
The number is printed on the screen, in an array, then followed by this error:

Traceback (most recent call last):
File "zero4.py", line 49, in <module>
for i in range(0,len(segmentPattern[number])):
TypeError: list indices must be integers, not list

The error is now situated in this line:
for i in range(0,len(segmentPattern[number])):
seg[segmentPattern[number]].off()


This is the code I have at the moment

Code: Select all

#https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=91796&p=842195&hilit=7+segment+display+bertwert&sid=9f4ef1c1caa4e6004aa59dd4c9b4f4a1#p842195 and http://www.instructables.com/id/Controlling-a-7-segment-4-digit-display-with-a-Ras/?ALLSTEPS
#transform from gpio to gpiozero

from gpiozero import LED
import time

seg = [LED(8,active_high=False),LED(18,active_high=False),LED(10,active_high=False),
      LED(9,active_high=False),LED(11,active_high=False),LED(25,active_high=False),
      LED(22,active_high=False)]
segmentPattern = [[0,1,2,3,4,6],[1,2],[0,1,5,4,3],[0,1,2,3,5],[1,2,5,6],[0,2,3,5,6], #0 to 5
                 [0,2,3,4,5,6],[0,1,2],[0,1,2,3,4,5,6],[0,1,2,5,6],[0,1,2,4,5,6] ] #6 to 9



digits = [LED(7,active_high=True),LED(24,active_high=True),LED(23,active_high=True),
         LED(17,active_high=True)]          



num = {' ':(0,0,0,0,0,0,0),
    '0':(1,1,1,1,1,1,0),
    '1':(0,1,1,0,0,0,0),
    '2':(1,1,0,1,1,0,1),
    '3':(1,1,1,1,0,0,1),
    '4':(0,1,1,0,0,1,1),
    '5':(1,0,1,1,0,1,1),
    '6':(1,0,1,1,1,1,1),
    '7':(1,1,1,0,0,0,0),
    '8':(1,1,1,1,1,1,1),
    '9':(1,1,1,1,0,1,1),
    'H':(0,1,1,0,1,1,1),
    'I':(0,1,1,0,0,0,0),
    'G':(1,0,1,1,1,1,0)
       }

try:

    while True:

        n = 1234 #number or value of a variable. 
	number = [int(x) for x in str(n)]        
	print (number)

        

        for digit in range(4):
            for i in range(0,7):
                seg[i].on()
                for i in range(0,len(segmentPattern[number])):
                     seg[segmentPattern[number][i]].off()

                #GPIO.output(segments[loop], num[s[digit]][loop])
                    
           # GPIO.output(digits[digit], 0)
           # time.sleep(0.001)
           # GPIO.output(digits[digit], 1)
            

except KeyboardInterrupt:
    GPIO.cleanup()
already a big thanks!

jahboater
Posts: 4767
Joined: Wed Feb 04, 2015 6:38 pm

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 4:49 pm

I think this is a great product.
The chip (MAX7219CNG) has memory which makes it all easier.

https://thepihut.com/collections/raspbe ... ts/zeroseg

It fits on any Pi.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: controlling 4-digit display with gpiozero

Thu Sep 29, 2016 6:29 pm

depauw wrote:Did some code-cleaning an introduced the proposed code. We're already one step futher!
What hardware do you have? Is this a display that you are supposed to quickly light the segments from one digit and then the next and the next and then the next and back to the first in a loop?

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Fri Sep 30, 2016 6:39 am

I'm using this type of display (I attached a datasheet)
SH5461AS.gif

tom.slick
Posts: 190
Joined: Wed Jan 06, 2016 9:23 pm

Re: controlling 4-digit display with gpiozero

Fri Sep 30, 2016 7:08 am

Why try to combine to different examples for two different sets of hardware and try to make one working version of it?
Take the working version for the 4 digit display and change the GPIO command to work with gpiozero.
It's a library to library port. You don't need to worry about the code from one tutorial. Just exchange code in the working GPIO example to work with gpiozero.

And look at the error message
You never look at the message
seg[segmentPattern[number]].off()
number is a string, you need an int.

But start over and take the working code and just port it to the new module.
Substitute command for command and don't try to change the logic.

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Tue Oct 11, 2016 4:46 pm

Hello, Iim back again.
I took on the advice of tom.slick and took a long look at the code...
I decided to try out one solution and stopped mixing 2 types of code.
Now, I understand a bit more what is happening, but I haven't reached a working code yet....

This is what I've got so far.
The segmentpatern controls the ledsegments to form a number.
I took the same concept to control the digit, using a positionPattern.

I think my issues are:
- how to read each individual digit of a 4-digit number
- create a codeline which says for example for the number 1234 'for the digit on position 0: light up the segmentPattern of 1, for position 1 the pattern of 2 and so on.

Code: Select all

#transform from gpio to gpiozero

from gpiozero import LED
import time

seg = [LED(8,active_high=False),LED(18,active_high=False),LED(10,active_high=False),
      LED(9,active_high=False),LED(11,active_high=False),LED(25,active_high=False),
      LED(22,active_high=False)]
segmentPattern = [[0,1,2,3,4,6],[1,2],[0,1,5,4,3],[0,1,2,3,5],[1,2,5,6],[0,2,3,5,6], #0 to 5
                 [0,2,3,4,5,6],[0,1,2],[0,1,2,3,4,5,6],[0,1,2,5,6],[0,1,2,4,5,6] ] #6 to 9


position = [LED(7,active_high=False),LED(24,active_high=False),LED(23,active_high=False),
         LED(17,active_high=False)]          
positionPattern = [[0],[1],[2],[3]]


#routine to clear and then write to display
def digdisp(digit):
    # clear display
    for i in range(0,7):
		seg[i].on()

    # display digit
    for j in range (0,4):
		
		for i in range (0,len(segmentPattern[digit])):
			
			position[j].on() # this is not working
			seg[segmentPattern[digit][i]].off()
		

try:
	while True:
         for nr in range (0,110):
				
				digdisp(nr)
				time.sleep(0.5)
				print nr

except KeyboardInterrupt:
    GPIO.cleanup()
I hope someone can help me out here.

kind regards,
Christophe

tom.slick
Posts: 190
Joined: Wed Jan 06, 2016 9:23 pm

Re: controlling 4-digit display with gpiozero

Tue Oct 11, 2016 9:53 pm

depauw wrote:Hello, Iim back again.
I took on the advice of tom.slick and took a long look at the code...
I decided to try out one solution and stopped mixing 2 types of code.
Now, I understand a bit more what is happening, but I haven't reached a working code yet....

This is what I've got so far.
The segmentpatern controls the ledsegments to form a number.
I took the same concept to control the digit, using a positionPattern.

I think my issues are:
- how to read each individual digit of a 4-digit number
- create a codeline which says for example for the number 1234 'for the digit on position 0: light up the segmentPattern of 1, for position 1 the pattern of 2 and so on.

Code: Select all

#transform from gpio to gpiozero

from gpiozero import LED
import time

seg = [LED(8,active_high=False),LED(18,active_high=False),LED(10,active_high=False),
      LED(9,active_high=False),LED(11,active_high=False),LED(25,active_high=False),
      LED(22,active_high=False)]
segmentPattern = [[0,1,2,3,4,6],[1,2],[0,1,5,4,3],[0,1,2,3,5],[1,2,5,6],[0,2,3,5,6], #0 to 5
                 [0,2,3,4,5,6],[0,1,2],[0,1,2,3,4,5,6],[0,1,2,5,6],[0,1,2,4,5,6] ] #6 to 9


position = [LED(7,active_high=False),LED(24,active_high=False),LED(23,active_high=False),
         LED(17,active_high=False)]          
positionPattern = [[0],[1],[2],[3]]


#routine to clear and then write to display
def digdisp(digit):
    # clear display
    for i in range(0,7):
		seg[i].on()

    # display digit
    for j in range (0,4):
		
		for i in range (0,len(segmentPattern[digit])):
			
			position[j].on() # this is not working
			seg[segmentPattern[digit][i]].off()
		

try:
	while True:
         for nr in range (0,110):
				
				digdisp(nr)
				time.sleep(0.5)
				print nr

except KeyboardInterrupt:
    GPIO.cleanup()
I hope someone can help me out here.

kind regards,
Christophe
This is untested, but this should give you an idea on how to proceed.

Code: Select all

from gpiozero import LED
import time

segments = [LED(8, active_high=False),
            LED(18, active_high=False),
            LED(10, active_high=False),
            LED(9, active_high=False), 
            LED(11, active_high=False), 
            LED(25, active_high=False), 
            LED(22, active_high=False)]

digits = [LED(7, active_high=False), LED(24, active_high=False),
          LED(23, active_high=False), LED(17, active_high=False)]

# dict, values are segments to light up to display a number/letter
num = {' ':(0, 0, 0, 0, 0, 0, 0),
       '0':(1, 1, 1, 1, 1, 1, 0),
       '1':(0, 1, 1, 0, 0, 0, 0),
       '2':(1, 1, 0, 1, 1, 0, 1),
       '3':(1, 1, 1, 1, 0, 0, 1),
       '4':(0, 1, 1, 0, 0, 1, 1),
       '5':(1, 0, 1, 1, 0, 1, 1),
       '6':(1, 0, 1, 1, 1, 1, 1),
       '7':(1, 1, 1, 0, 0, 0, 0),
       '8':(1, 1, 1, 1, 1, 1, 1),
       '9':(1, 1, 1, 1, 0, 1, 1),
       'H':(0, 1, 1, 0, 1, 1, 1),
       'I':(0, 1, 1, 0, 0, 0, 0),
       'G':(1, 0, 1, 1, 1, 1, 0)}

try:
    while True:
        n = 1234 #number or value of a variable.
        print (n)

        if n > 9999:
            s = 'HIGH'
        else:
            # This is how you make your number a 4 digit string.
            # it will pad the beginning with spaces 
            string = str(n).rjust(4)

             # or you can pad it with zeros
            #string = "%04d" % (n)

        for digit in range(4):
            for loop in range(0, 7):
                # first digit of 1234
                # the number in the dict
                # '1':(0, 1, 1, 0, 0, 0, 0)
                # value to display 1
                # string[digit]  # digit = "1"
                # num[ string[digit] ]
                # the tuple in the dict that represents the value of the segments
                # (0, 1, 1, 0, 0, 0, 0)
                # loop points to each segment
                # num[ string[digit] ][loop]  # loop = 0
                # 0
                # each segment needs to be turned on or off.
                if num[string[digit]][loop]:
                    # if the value of a segment should be HIGH turn it on
                    segments[loop].on()
                else:
                    # if LOW turn it off
                    segments[loop].off()

            # cycle the display
            digits[digit].off()
            time.sleep(0.001)
            digits[digit].on()

except KeyboardInterrupt:
    pass

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Thu Oct 13, 2016 7:19 am

Wow! All respect for tom.slick !!!

When I first ran the code, the digits were displayed in an inverted way. What was on had to be off, and vice versa.
So I've changed the on and off's in the code and..... It works!!!!!

This is the working code for my 4-digit display of the 'common cathode' type.

Thanks a lot!!!!

Code: Select all

from gpiozero import LED
import time

segments = [LED(8, active_high=False),
            LED(18, active_high=False),
            LED(10, active_high=False),
            LED(9, active_high=False), 
            LED(11, active_high=False), 
            LED(25, active_high=False), 
            LED(22, active_high=False)]

digits = [LED(7, active_high=False), LED(24, active_high=False),
          LED(23, active_high=False), LED(17, active_high=False)]

# dict, values are segments to light up to display a number/letter
num = {' ':(0, 0, 0, 0, 0, 0, 0),
       '0':(1, 1, 1, 1, 1, 1, 0),
       '1':(0, 1, 1, 0, 0, 0, 0),
       '2':(1, 1, 0, 1, 1, 0, 1),
       '3':(1, 1, 1, 1, 0, 0, 1),
       '4':(0, 1, 1, 0, 0, 1, 1),
       '5':(1, 0, 1, 1, 0, 1, 1),
       '6':(1, 0, 1, 1, 1, 1, 1),
       '7':(1, 1, 1, 0, 0, 0, 0),
       '8':(1, 1, 1, 1, 1, 1, 1),
       '9':(1, 1, 1, 1, 0, 1, 1),
       'H':(0, 1, 1, 0, 1, 1, 1),
       'I':(0, 1, 1, 0, 0, 0, 0),
       'G':(1, 0, 1, 1, 1, 1, 0)}

try:
    while True:
        n = 9101 #number or value of a variable.
        print (n)

        if n > 9999:
            string = 'HIGH'
        else:
            # This is how you make your number a 4 digit string.
            # it will pad the beginning with spaces 
            string = str(n).rjust(4)

             # or you can pad it with zeros
            #string = "%04d" % (n)

        for digit in range(4):
            for loop in range(0, 7):
                # first digit of 1234
                # the number in the dict
                # '1':(0, 1, 1, 0, 0, 0, 0)
                # value to display 1
                # string[digit]  # digit = "1"
                # num[ string[digit] ]
                # the tuple in the dict that represents the value of the segments
                # (0, 1, 1, 0, 0, 0, 0)
                # loop points to each segment
                # num[ string[digit] ][loop]  # loop = 0
                # 0
                # each segment needs to be turned on or off.
                if num[string[digit]][loop]:
                    # if the value of a segment should be HIGH turn it on
                    segments[loop].off()
                else:
                    # if LOW turn it off
                    segments[loop].on()

            # cycle the display
            digits[digit].on()
            time.sleep(0.001)
            digits[digit].off()

except KeyboardInterrupt:
		pass
		print " clean program exit."

tom.slick
Posts: 190
Joined: Wed Jan 06, 2016 9:23 pm

Re: controlling 4-digit display with gpiozero

Thu Oct 13, 2016 9:19 am

depauw wrote:Wow! All respect for tom.slick !!!

When I first ran the code, the digits were displayed in an inverted way. What was on had to be off, and vice versa.
So I've changed the on and off's in the code and..... It works!!!!!

This is the working code for my 4-digit display of the 'common cathode' type.

Thanks a lot!!!!

Code: Select all

from gpiozero import LED
import time

segments = [LED(8, active_high=False),
            LED(18, active_high=False),
            LED(10, active_high=False),
            LED(9, active_high=False), 
            LED(11, active_high=False), 
            LED(25, active_high=False), 
            LED(22, active_high=False)]

digits = [LED(7, active_high=False), LED(24, active_high=False),
          LED(23, active_high=False), LED(17, active_high=False)]

# dict, values are segments to light up to display a number/letter
num = {' ':(0, 0, 0, 0, 0, 0, 0),
       '0':(1, 1, 1, 1, 1, 1, 0),
       '1':(0, 1, 1, 0, 0, 0, 0),
       '2':(1, 1, 0, 1, 1, 0, 1),
       '3':(1, 1, 1, 1, 0, 0, 1),
       '4':(0, 1, 1, 0, 0, 1, 1),
       '5':(1, 0, 1, 1, 0, 1, 1),
       '6':(1, 0, 1, 1, 1, 1, 1),
       '7':(1, 1, 1, 0, 0, 0, 0),
       '8':(1, 1, 1, 1, 1, 1, 1),
       '9':(1, 1, 1, 1, 0, 1, 1),
       'H':(0, 1, 1, 0, 1, 1, 1),
       'I':(0, 1, 1, 0, 0, 0, 0),
       'G':(1, 0, 1, 1, 1, 1, 0)}

try:
    while True:
        n = 9101 #number or value of a variable.
        print (n)

        if n > 9999:
            string = 'HIGH'
        else:
            # This is how you make your number a 4 digit string.
            # it will pad the beginning with spaces 
            string = str(n).rjust(4)

             # or you can pad it with zeros
            #string = "%04d" % (n)

        for digit in range(4):
            for loop in range(0, 7):
                # first digit of 1234
                # the number in the dict
                # '1':(0, 1, 1, 0, 0, 0, 0)
                # value to display 1
                # string[digit]  # digit = "1"
                # num[ string[digit] ]
                # the tuple in the dict that represents the value of the segments
                # (0, 1, 1, 0, 0, 0, 0)
                # loop points to each segment
                # num[ string[digit] ][loop]  # loop = 0
                # 0
                # each segment needs to be turned on or off.
                if num[string[digit]][loop]:
                    # if the value of a segment should be HIGH turn it on
                    segments[loop].off()
                else:
                    # if LOW turn it off
                    segments[loop].on()

            # cycle the display
            digits[digit].on()
            time.sleep(0.001)
            digits[digit].off()

except KeyboardInterrupt:
		pass
		print " clean program exit."
Your welcome

User avatar
scruss
Posts: 2548
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: controlling 4-digit display with gpiozero

Thu Oct 13, 2016 12:12 pm

depauw wrote:Wow! All respect for tom.slick !!!

When I first ran the code, the digits were displayed in an inverted way. What was on had to be off, and vice versa.
So I've changed the on and off's in the code and..... It works!!!!!
That's really cool, and tom.slick did a great job here

… but do you understand what the code is doing so you can do more projects with gpiozero?
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

depauw
Posts: 44
Joined: Mon Nov 09, 2015 2:12 pm

Re: controlling 4-digit display with gpiozero

Mon Oct 17, 2016 9:21 am

I think I've got the hang of it, but I wouldn't have found it myself.
I took out a piece of paper, so I could write down the values of digit, loop, segments,.... so I could really understand what's going on, when the code is executed.

This certainly has been a good learning experience!!

Return to “Python”