Let the snake run
This challenge has been written by Ágota Klacsákné Tóth and is part of the EU CODE WEEK CHALLENGES.
Target Audience
  1. Primary School students (6 to 12 years)
  2. Lower Secondary School students (12 to 16 years)
Experience
  1. Beginner
Duration
  1. 30 minutes
Recommended Materials
  1. micro:bits (for every student if possible)
  2. laptop or computer for makecode.microbit.org editor
Purpose
  1. To code the snake's movement on their own micro:bit.
  2. To set the correct placing and timing for the joint animation.
Description
Students must write codes to navigate the snake through micro:bits next to each other. It has to be done in a way that it looks like the snake is running from one micro:bit to the other.
Instructions
  • Design a track that goes through several micro:bits next to each other (e.g., forming a 2x2 square).
  • Write codes as a snake moves along a track.
  • Work on your own device then put them together and run the code.
  • Consider the timing and placement: If the snake goes out of one micro:bit, it will appear on the next micro:bit.
  • Further challenges: With micro:bit v2, play music until the snake leaves your device.
  • Design the snake by changing the brightness of the LEDs.
  • Try longer, or more snakes.
Share the link to your work in your Instagram Bio: tap the Edit Profile button on your Instagram and add the link to your work in the Website field. After that, create a new post, add a screenshot of your work, write “Link in Bio”, add the hashtag #EUCodeWeekChallenge and mention @CodeWeekEU.
Example
This is an example for a 6 pixel long snake with4 micro:bits forming a 2x2 square:
1. Coding the starting micro:bit (the teacher can do it)
All codes are initiated by this micro:bit, which sends a radio signal to other micro:bits when the A button is pressed.
2. Coding the snake movement
Each micro:bit must be in the same radio group as the starting micro:bit.
Allanimations start when the radio signal is received.
The animation of the first microbit is immediately visible, the others wait until the snake gets there.
The time between the two phases determines the speed of the snake.
Click here to download this challenge as a word document.