#jingle bells demonstration
#copytight Microbitsandbobs.co.uk

from microbit import *
import music
import neopixel
from random import randint

music.set_tempo(ticks=4, bpm=120)
# play Jingle Bells - (c) James Peirpont 1857.
jingle = [
    'e:2','e:2','e:4',
    'e:2','e:2','e:4',
    'e:2','g:2','c','d',
    'e:8',
    'f:2','f:2','f:3',
    'f:1','f:2','e:2',
    'e:2','e:1','e:1',
    'e:2','d:2','d:2',
    'e:2','d:4','g:4',
    'e:2','e:2','e:4',
    'e:2','e:2','e:4',
    'e:2','g:2','c','d',
    'e:8','f:2','f:2','f:2',
    'f:2','f:2','e:2',
    'e:2','e:1','e:1',
    'g:2','g:2','f:2',
    'd:2', 'c:4'
 
]





np = neopixel.NeoPixel(pin3, 8)
while True:

    if button_a.is_pressed():
        music.play(jingle, wait = False)
    

        
    for pixel_id in range(0, len(np)):
        
        red = randint(0, 255)
        green = randint(0, 255)
        blue = randint(0, 255)

        # Assign the current LED a random red, green and blue value between 0 and 60
        np[pixel_id] = (red, green, blue)

        # Display the current pixel data on the Neopixel strip
        np.show()
        #sleep(5)