My code wont work. I’m trying to make it so that how big of a light level will display on the led. The smallest value is [0,0] in the leds, so when there is no light I want the [0,0] led to show up, then it goes up progressing.
I used Python.
Old_Plot = [0,0]
PlotX = Old_Plot[0]
PlotY = Old_Plot[1]
def Functionality():
global PlotX, PlotY, Old_Plot
reading = input.light_level()
final_reading = Math.round(abs(reading / 25) * 2.5) # Nei, dette er ikke fra google, abs står får "Absolute Value" det gjør negative tall om til positive, so eks: -3 blir til 3
if not final_reading == 0:
final_reading -= 1 # Fordi datamaskiner starter alltid på 0
if final_reading > 25:
final_reading = 25
# print(str(final_reading))
PlotX = final_reading / 5
if PlotX >= (PlotY * 5) + 1:
PlotY += 1
PlotX = 0
print(PlotX)
print(PlotY)
led.unplot(Old_Plot[0], Old_Plot[1])
led.plot(PlotX, PlotY)
Old_Plot = [PlotX,PlotY]
while True:
Functionality()