Menu Close

Robotics 17/05/2023

what we have done:

from onepixel import Neopixel
np = Neopixel(2,0,18, "GRB")
color = np.colorHSV(0, 255, 255)
np.fill(color)
np.show()

add the following (to line 3) and modify the line 4:

from onepixel import Neopixel
np = Neopixel(2,0,18, "GRB")
hue = int(0)
color = np.colorHSV(hue, 255, 255)
np.fill(color)
np.show()

then add the following loop(s) (things that with a # are not important):

from onepixel import Neopixel
np = Neopixel(2,0,18, "GRB")
hue = int(0)
color = np.colorHSV(hue, 255, 255)
np.fill(color)
np.show()

#main loop
while True:
    while hue < 65536:
        hue = int(hue+5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()
        
    while hue > 0:
        hue = int(hue-5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()

then add the following lines:

from onepixel import Neopixel
np = Neopixel(2,0,18, "GRB")
hue = int(0)
color = np.colorHSV(hue, 255, 255)
np.fill(color)
np.show()

#main loop
while True:
    while hue < 65536:
        hue = int(hue+5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()
        
    while hue > 0:
        hue = int(hue-5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()

then the following loop (press backspace after the new line!):

from onepixel import Neopixel
np = Neopixel(2,0,18, "GRB")
hue = int(0)
color = np.colorHSV(hue, 255, 255)
np.fill(color)
np.show()

#main loop
while True:
    while hue < 65536:
        hue = int(hue+5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()
        
    while hue > 0:
        hue = int(hue-5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()

then the following lines:

from onepixel import Neopixel
np = Neopixel(2,0,18, "GRB")
hue = int(0)
color = np.colorHSV(hue, 255, 255)
np.fill(color)
np.show()

#main loop
while True:
    while hue < 65536:
        hue = int(hue+5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()
        
    while hue > 0:
        hue = int(hue-5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()

finished code:

from onepixel import Neopixel
np = Neopixel(2,0,18, "GRB")
hue = int(0)
color = np.colorHSV(hue, 255, 255)
np.fill(color)
np.show()

#main loop
while True:
    while hue < 65536:
        hue = int(hue+5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()
        
    while hue > 0:
        hue = int(hue-5)
        color = np.colorHSV(0,0,0)
        color = np.colorHSV(hue, 255, 255)
        np.fill(color)
        np.show()