i'm trying to run my code but i've been stuck for hours on a syntax error. I've tried diffrent if statement levels, rewriting the part, etc... nothing changes. Anyone has any idea? thanks
I've used online chackers too but with no results. I run the code using Python 3, can't run it with older versions.
The error happens on all the lines of this part of the code:
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
Here's the full code, it's a RGB strip timer
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
pixels.fill((brightmaxred, 0, bright)
You've got two left parentheses and only one right.