# Light LEDs at random and make them fade over time
#
# Usage:
#
#    led_dance(delay)
#
# 'delay' is the time between each new LED being turned on.
#
# TODO The random number generator is not great. Perhaps the accelerometer
# or compass could be used to add entropy.

import microbit

def led_dance(delay):
    dots = [ [0]*5, [0]*5, [0]*5, [0]*5, [0]*5 ]
    microbit.display.set_display_mode(1)
    while True:
        dots[microbit.random(5)][microbit.random(5)] = 128
        for i in range(5):
            for j in range(5):
                microbit.display.image.set_pixel(i, j, dots[i][j])
                dots[i][j] = int(dots[i][j]/2)
        microbit.sleep(delay)

led_dance(100)

@@ -355,49 +355,8 @@
 5 %5D%0A
-    microbit.display.set_display_mode(1)%0A
     
@@ -426,10 +426,8 @@
 %5D = 
-12
 8%0A  
@@ -519,14 +519,8 @@
 lay.
-image.
 set_
@@ -576,11 +576,11 @@
 %5D = 
-int
+max
 (dot
@@ -590,10 +590,15 @@
 %5D%5Bj%5D
-/2
+ - 1, 0
 )%0A  

Modify led_dance to use new display API.