0

I need to make stopwatch on a 7 segment display. But when I try it, it blinks. I don't want this effect, but I don't know how to write code for a stopwatch that doesn't blink the whole time. I tried making my stopwatch with sleep library. This is my code that allows me to display chars on a 7 segment display.

import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
displeje = (18,22,32,36,38,40)
GPIO.setup(displeje,GPIO.OUT, initial=1)
segments = (13,11,35,33,31,15,29,37)
GPIO.setup(segments,GPIO.OUT, initial=1)
num = {' ':(1,1,1,1,1,1,1,1),
       'F':(0,1,1,1,0,0,0,1),
       'A':(0,0,0,1,0,0,0,1),
       'C':(0,1,1,0,0,0,1,1),
       'b':(1,1,0,0,0,0,0,1),
       'd':(1,0,0,0,0,1,0,1),
       'E':(0,1,1,0,0,0,0,1),
       'H':(1,0,0,1,0,0,0,1),
       'n':(1,1,0,1,0,1,0,1),
       'o':(1,1,0,0,0,1,0,1),
       'P':(0,0,1,1,0,0,0,1),
       'r':(1,1,1,1,0,1,0,1),
       'S':(0,1,0,0,1,0,0,1),
       'I':(1,1,1,1,0,0,1,1),
       'L':(1,1,1,0,0,0,1,1),
       '0':(0,0,0,0,0,0,1,1),
       'O':(0,0,0,0,0,0,1,1),
       '1':(1,0,0,1,1,1,1,1),
       '2':(0,0,1,0,0,1,0,1),
       '3':(0,0,0,0,1,1,0,1),
       '4':(1,0,0,1,1,0,0,1),
       '5':(0,1,0,0,1,0,0,1),
       '6':(0,1,0,0,0,0,0,1),
       '7':(0,0,0,1,1,1,1,1),
       '8':(0,0,0,0,0,0,0,1),
       '9':(0,0,0,1,1,0,0,1),
       '-':(1,1,1,1,1,1,0,1)
    } 

def seg(show):
    for displej in range(6):
        show = str(show).ljust(6)
        GPIO.output(segments, (num[show[displej]]))
        GPIO.output(displeje[displej],1)
        sleep(.001)
        GPIO.output(displeje[displej],0)
Cache Staheli
  • 3,510
  • 7
  • 32
  • 51
ada dasda
  • 1
  • 2
  • Well it looks like you constantly change the output... I'm not convinced that this is the way how it works. – Willem Van Onsem Feb 02 '17 at 22:09
  • I call function seg in infinity loop to display sth but when i want to make stopwatch i want to make this argument in seg chaning but when i try it. It also do another sleep that affect on 7 segments and starts blink .It display blinkly not cleanly. – ada dasda Feb 02 '17 at 22:16
  • but afaik you do not show us the part that makes a stopwatch. How can you expect us to debug code we cannot see?! – Willem Van Onsem Feb 02 '17 at 22:17
  • from time import sleep def casovac(x): while(x>=0): x = x-1 seg(x) sleep(1) – ada dasda Feb 02 '17 at 22:19
  • please [`[edit]`](http://stackoverflow.com/posts/42013188/edit) your question. – Willem Van Onsem Feb 02 '17 at 22:20

0 Answers0