1

我正在尝试运行我的代码,但由于语法错误,我已经被困了好几个小时。我尝试了不同的 if 语句级别、重写部分等......没有任何变化。有人有什么想法吗?谢谢

我也使用过在线破解者,但没有任何结果。我使用 Python 3 运行代码,不能使用旧版本运行它。

错误发生在这部分代码的所有行上:

if alarmdown == 1:
        bright = bright - 1
        pixels.fill((brightmaxred, 0, bright)
        if bright == 10:
                alarmdown = 0
elif alarmdown == 0:
        bright = bright + 1
        pixels.fill((brightmaxred, 0, bright)
        if bright == brightmaxblue:
                alarmdown = 1

这是完整的代码,它是一个 RGB 条形计时器

import time
import board
import neopixel
pixels = neopixel.NeoPixel(board.D18, 24)


#variables
terminate = 0
startup = 1
bright = 1
selectpix = 0
goblue = 0
pixelstart = (0, 0, 100)
order = 1
timerexpired = 0
alarmdown = 1

brightmaxblue = 20
brightmaxred = 30

currentlow = 0
currenthigh = 23

#set timer speed
totaltime = 15 #how many seconds? approximation
timetotal = totaltime / (brightmaxred * 30)

#set a clean board
pixels.fill((0, 0, 0))

#if til true
while terminate == 0:
        if startup == 1:
                goblue = goblue + 1
                pixels.fill((0, 0, goblue))
                time.sleep(timetotal)
                if  goblue == brightmaxblue:
                        startup = 0
                        timer = 1
        elif startup == 0:
#start from the pixel no. 0 - 23 - 1 - 22 - ...
                while timer == 1:
                        pixels[selectpix] = (bright, 0, brightmaxblue)
                        bright = bright + 1
                        time.sleep(timetotal)
                        if  bright == brightmaxred:
                                if currentlow == 12:
                                        timer = 0
                                        timerexpired = 1
                                elif selectpix == currentlow:
                                        selectpix = currenthigh
                                        currentlow = currentlow + 1
                                elif selectpix == currenthigh:
                                        selectpix = currentlow
                                        currenthigh = currenthigh - 1
                                bright = 0
                if timerexpired == 1:
                        if alarmdown == 1:
                                bright = bright - 1
                                pixels.fill((brightmaxred, 0, bright)
                                if bright == 10:
                                        alarmdown = 0
                        elif alarmdown == 0:
                                bright = bright + 1
                                pixels.fill((brightmaxred, 0, bright)
                                if bright == brightmaxblue:
                                        alarmdown = 1
4

1 回答 1

4
pixels.fill((brightmaxred, 0, bright)

你有两个左括号,只有一个右括号。

于 2020-02-20T23:09:50.583 回答