Spiel: Neopixel

Spiel: Neopixel

Light up a neopixel strip by rotating your Calliope mini in different directions.

Medium

30 mins

from 10 years on

1Course of the game
  1. The Calliope mini is rotated in different directions.
  2. The rotations are detected by the Calliope mini's position sensor. Rotations on the x-axis switch on the first LEDs up to half of the strip and rotations on the y-axis switch on the second half.
  3. For an increased difficulty level, a random LED is switched off every second.
  4. Leuchten alle LEDs des Streifens, ist das Spiel gewonnen und es erscheint ein Regenbogen.
2Accessories

The game works with a NeoPixel LED strip.

3Programming

Programming is carried out in the MakeCode Editor, and the "NeoPixel ” extension must also be loaded.

Code

  • The first block determines the length and the connection of the NeoPixel strip.
  • The two “Interval” blocks divide the strip into two areas and enable the division for the x and y directions of rotation.
  • The values of the position sensor are distributed over a specific area of the NeoPixel and stored in a variable.
  • For clarity, half is divided again to cover negative (-90° to 0°) and positive (0° to 90°) rotation angles.
  • The previously saved variable can be saved in a list to determine when all LEDs are switched on.
  • Every second, an LED is switched off to make the game a little more difficult. To do this, a random value is removed from the list and the corresponding LED is switched off.