In this project, we will draw some text on the LED Matrix and scroll it across the screen like an electronic banner.

Your breadboard should still have the circuit we wired in the project. As a reminder, here is what the breadboard should look like:

In this project, we're going to create some text to display on the LED Matrix, define the starting position of the text when we first display it, and then scroll the text by changing the position of it on the LED Matrix each time through a loop.

Again, for consistency, we'll format the code as a Game Loop. Here is what the final code should look like:

from rstem.led_matrix import FrameBuffer from rstem.led_matrix import Text import time # Initialize the game environment fb = FrameBuffer() text = Text("Press to play!") x_position = 8 while True: # Get user input # Update the game world x_position = x_position - 1 if x_position < -text.width: x_position = 8 # Draw graphics on the screen fb.erase() fb.draw(text, (x_position, 0)) fb.show() # Wait for some period of time time.sleep(0.1)

Give it a try. You should now see the text scroll across the screen. In future projects, we'll use code similar to this as part of one of our LED Matrix games.

1. Can you reverse the text so that it will only be readable with a mirror?

2. Can you add a button that, when pressed, switches the text to something different? Can you make additional button presses scroll through a list of text messages?

3. Can you make a button press cause the text to scroll faster? How about speeding up the text with each successive button press?

4. In our project, the vertical position of the text doesn't change. Can you modify the code so that the text bounces — in other words, as it moves across the display, alternate the Y position up and down one point.