Introduction: Christmas Dancing Scratch

About: I write software and do other stuff too.

When you press the button on the breadboard, the LEDs start flashing, Jingle Bells starts playing, and Scratch starts dancing in his Christmas hat. Here is a video:

If you want to learn how to do these basic things, you can read the following sections!

In this project we brought together:

  1. The kids' knowledge of music from their piano classes
  2. GPIO connected LEDs
  3. GPIO connected button
  4. Art
  5. Animation
  6. Event handling

into a silly afternoon project.

Overall I think it was cool to show the kids how to do basic programming things as well as to let them wire up a couple of things to the GPIO. They had a blast making Scratch dance around. Nevertheless, for future family coding events we'll stick with Arduino, or a standard programming language + an ssh connection to the pi. The 3B+ Desktop is painfully slow and Scratch can't shine in such an environment since everything requires snappy drag and drop and click etc. to be pleasant to use.

Supplies

  1. Raspberry Pi 3
  2. Basic beginner kit ( leds, button, breadboard, wires ).

Step 1: Wiring

Wiring this up is pretty simple - just 2 leds and a button.

The button has a 1K ohm resistor and I put 100 ohm resistors on the LEDs. The wiring is shown in the image.

Looking at the diagram here and the images I've shared, you'll see that the button is connected to the 3v pin and pin 18. When the user hits the button, gpio pin 18 goes high and Scratch handles that event and starts the show.

The leds are attached to GPIO pins 14 and 15, which allows Scratch to flash them by setting them high/low for on/off.

Step 2: Code

The code is shown in the linked video.

Here's how it works:
1. Hit the Green Flag to start the program.

2. The program waits for a button press event.

3. When a button press event is received, the program sends a signal to a few receivers.

4a. ReceiverA starts the music. The music is just the notes of Jingle Bells that the kids read from their Alfred's piano book and translated into Scratch.

4b. ReceiverB starts turning Scratch back and forth so it looks like he's dancing.

4c. ReceiverC starts the lights flashing alternating red, green, red, ...

5. After 32 seconds everything stops. We had the lights and dancing go on for 32 seconds, and the music was set to 120BPM, and there were 64 beats, so this means 32 seconds.

NOTE: You'll need to add the GPIO pins to your project. Not hard at all, just read how to do it there.

Block Code Contest

Participated in the
Block Code Contest